kopia lustrzana https://github.com/c9/core
fix plugin manager on windows
rodzic
fd9092aabe
commit
b5b6255302
|
@ -7,6 +7,17 @@ module.exports = function(options) {
|
||||||
assert(options.workspaceName, "Option 'workspaceName' must be set");
|
assert(options.workspaceName, "Option 'workspaceName' must be set");
|
||||||
assert(options.home, "Option 'home' must be set");
|
assert(options.home, "Option 'home' must be set");
|
||||||
assert(options.platform, "Option 'platform' must be set");
|
assert(options.platform, "Option 'platform' must be set");
|
||||||
|
|
||||||
|
// normalize workspacedir and home paths
|
||||||
|
function normalize(path) {
|
||||||
|
path = path.replace(/([^/])\/$/, "$1");
|
||||||
|
if (options.platform == "win32")
|
||||||
|
path = path.replace(/\\/g, "/");
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
options.workspaceDir = normalize(options.workspaceDir);
|
||||||
|
options.installPath = normalize(options.installPath);
|
||||||
|
options.home = normalize(options.home);
|
||||||
|
|
||||||
var workspaceDir = options.workspaceDir;
|
var workspaceDir = options.workspaceDir;
|
||||||
var debug = options.debug !== undefined ? options.debug : false;
|
var debug = options.debug !== undefined ? options.debug : false;
|
||||||
|
|
|
@ -348,10 +348,10 @@ define(function(require, exports, module) {
|
||||||
};
|
};
|
||||||
|
|
||||||
plugin.escapeShell = function(cmd) {
|
plugin.escapeShell = function(cmd) {
|
||||||
var re = /([\#\&\;\`\|\*\?<>\^\(\)\[\]\{\}\$\,\x0A\xFF\' \"])/g;
|
var re = /([\#\&\;\`\|\*\?<>\^\(\)\[\]\{\}\$\,\x0A\xFF\' \"\\])/g;
|
||||||
return cmd.replace(re, "\\$1");//.replace(/^~/, "\\~");
|
return cmd.replace(re, "\\$1");//.replace(/^~/, "\\~");
|
||||||
};
|
};
|
||||||
|
|
||||||
var cloneObject = plugin.cloneObject = function(obj) {
|
var cloneObject = plugin.cloneObject = function(obj) {
|
||||||
if (obj === null || typeof obj !== "object")
|
if (obj === null || typeof obj !== "object")
|
||||||
return obj;
|
return obj;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
main.consumes = [
|
main.consumes = [
|
||||||
"Plugin", "proc", "c9", "pubsub", "auth"
|
"Plugin", "proc", "c9", "pubsub", "auth", "util"
|
||||||
];
|
];
|
||||||
main.provides = ["plugin.installer"];
|
main.provides = ["plugin.installer"];
|
||||||
return main;
|
return main;
|
||||||
|
@ -8,10 +8,12 @@ define(function(require, exports, module) {
|
||||||
function main(options, imports, register) {
|
function main(options, imports, register) {
|
||||||
var Plugin = imports.Plugin;
|
var Plugin = imports.Plugin;
|
||||||
var c9 = imports.c9;
|
var c9 = imports.c9;
|
||||||
|
var util = imports.util;
|
||||||
var proc = imports.proc;
|
var proc = imports.proc;
|
||||||
var auth = imports.auth;
|
var auth = imports.auth;
|
||||||
var pubsub = imports.pubsub;
|
var pubsub = imports.pubsub;
|
||||||
|
|
||||||
|
var escapeShell = util.escapeShell;
|
||||||
var updates = options.updates;
|
var updates = options.updates;
|
||||||
var architect;
|
var architect;
|
||||||
|
|
||||||
|
@ -103,7 +105,7 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
function installPlugin(name, version, callback){
|
function installPlugin(name, version, callback){
|
||||||
proc.spawn("bash", {
|
proc.spawn("bash", {
|
||||||
args: ["-c", ["c9", "install", "--local", "--force", "--accessToken=" + auth.accessToken, name + "@" + version].join(" ")]
|
args: ["-c", ["c9", "install", "--local", "--force", "--accessToken=" + auth.accessToken, escapeShell(name) + "@" + escapeShell(version)].join(" ")]
|
||||||
}, function(err, process){
|
}, function(err, process){
|
||||||
if (err) return callback(err);
|
if (err) return callback(err);
|
||||||
|
|
||||||
|
@ -127,7 +129,7 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
function uninstallPlugin(name, callback){
|
function uninstallPlugin(name, callback){
|
||||||
proc.spawn("c9", {
|
proc.spawn("c9", {
|
||||||
args: ["remove", "--local", "--force", "--accessToken=" + auth.accessToken, name]
|
args: ["remove", "--local", "--force", "--accessToken=" + auth.accessToken, escapeShell(name)]
|
||||||
}, function(err, process){
|
}, function(err, process){
|
||||||
if (err) return callback(err);
|
if (err) return callback(err);
|
||||||
|
|
||||||
|
|
|
@ -580,14 +580,18 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
// Download tar file with template for plugin
|
// Download tar file with template for plugin
|
||||||
proc.execFile("bash", {
|
proc.execFile("bash", {
|
||||||
args: ["-c", ["curl", "-L", url, "--create-dirs", "-o", tarPathAbsolute].join(" ")]
|
args: ["-c", [
|
||||||
|
// using mkdirp since "--create-dirs" is broken on windows
|
||||||
|
"mkdir", "-p", util.escapeShell(dirname(tarPathAbsolute)), ";",
|
||||||
|
"curl", "-L", util.escapeShell(url), "-o", util.escapeShell(tarPathAbsolute)].join(" ")
|
||||||
|
]
|
||||||
}, function(err, stderr, stdout){
|
}, function(err, stderr, stdout){
|
||||||
if (err)
|
if (err)
|
||||||
return handleError(err);
|
return handleError(err);
|
||||||
|
|
||||||
// Untar tar file
|
// Untar tar file
|
||||||
proc.execFile("bash", {
|
proc.execFile("bash", {
|
||||||
args: ["-c", ["tar", "-zxvf", tarPath, "-C", pluginsDirAbsolute].join(" ")]
|
args: ["-c", ["tar", "-zxvf", util.escapeShell(tarPath), "-C", util.escapeShell(pluginsDirAbsolute)].join(" ")]
|
||||||
}, function(err, stderr, stdout){
|
}, function(err, stderr, stdout){
|
||||||
if (err)
|
if (err)
|
||||||
return handleError(err);
|
return handleError(err);
|
||||||
|
|
Ładowanie…
Reference in New Issue