kopia lustrzana https://github.com/c9/core
Use installer for installing plugins (and removing failure).
rodzic
52980d2c3a
commit
7fc4048213
|
@ -1,6 +1,6 @@
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
main.consumes = [
|
main.consumes = [
|
||||||
"Plugin", "proc", "c9", "pubsub", "auth", "util"
|
"Plugin", "proc", "c9", "pubsub", "auth", "util", "installer"
|
||||||
];
|
];
|
||||||
main.provides = ["plugin.installer"];
|
main.provides = ["plugin.installer"];
|
||||||
return main;
|
return main;
|
||||||
|
@ -12,6 +12,7 @@ define(function(require, exports, module) {
|
||||||
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 installer = imports.installer;
|
||||||
|
|
||||||
var async = require("async");
|
var async = require("async");
|
||||||
|
|
||||||
|
@ -107,53 +108,29 @@ define(function(require, exports, module) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function installPlugin(name, version, callback){
|
function installPlugin(name, version, callback){
|
||||||
proc.spawn("bash", {
|
// Headless installation of the plugin
|
||||||
args: ["-c", ["c9", "install", "--local", "--force", "--accessToken=" + auth.accessToken, escapeShell(name) + "@" + escapeShell(version)].join(" ")]
|
installer.createSession(name, version, function(session, options){
|
||||||
}, function(err, process){
|
session.install({
|
||||||
if (err) return callback(err);
|
"bash": "c9 install --local --force --accessToken=" + auth.accessToken
|
||||||
|
+ " " + escapeShell(name) + "@" + escapeShell(version)
|
||||||
var output = "";
|
|
||||||
process.stdout.on("data", function(c){
|
|
||||||
output += c;
|
|
||||||
});
|
|
||||||
process.stderr.on("data", function(c){
|
|
||||||
output += c;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
process.on("exit", function(code){
|
// Force to start immediately
|
||||||
if (code) {
|
session.start(callback, true);
|
||||||
var error = new Error(output);
|
}, function(){}, 2); // Force to not be administered
|
||||||
error.code = code;
|
|
||||||
return callback(error);
|
|
||||||
}
|
|
||||||
callback();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function uninstallPlugin(name, callback){
|
function uninstallPlugin(name, callback){
|
||||||
proc.spawn("c9", {
|
// Headless uninstallation of the plugin
|
||||||
args: ["remove", "--local", "--force", "--accessToken=" + auth.accessToken, escapeShell(name)]
|
installer.createSession(name, -1, function(session, options){
|
||||||
}, function(err, process){
|
session.install({
|
||||||
if (err) return callback(err);
|
"bash": "c9 remove --local --force --accessToken=" + auth.accessToken
|
||||||
|
+ " " + escapeShell(name)
|
||||||
var res = null;
|
|
||||||
process.stdout.on("data", function(c){
|
|
||||||
res = c.toString("utf8");
|
|
||||||
});
|
|
||||||
process.stderr.on("data", function(c){
|
|
||||||
err = c.toString("utf8");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
process.on("exit", function(code){
|
// Force to start immediately
|
||||||
if (code) {
|
session.start(callback, true);
|
||||||
var error = new Error(err);
|
}, function(){}, 2); // Force to not be administered
|
||||||
error.code = code;
|
|
||||||
return callback(error);
|
|
||||||
}
|
|
||||||
callback(null, res);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Lifecycle *****/
|
/***** Lifecycle *****/
|
||||||
|
@ -183,6 +160,11 @@ define(function(require, exports, module) {
|
||||||
*/
|
*/
|
||||||
installPlugins: installPlugins,
|
installPlugins: installPlugins,
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
installPlugin: installPlugin,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -146,7 +146,7 @@ EventEmitter.prototype.addListener = function(type, listener, plugin) {
|
||||||
|
|
||||||
if (m && m > 0 && eventList.length > m) {
|
if (m && m > 0 && eventList.length > m) {
|
||||||
eventList.warned = true;
|
eventList.warned = true;
|
||||||
console.error('(node) warning: possible EventEmitter memory '
|
console.error('warning: possible EventEmitter memory '
|
||||||
+ 'leak detected. " + eventList.length + " listeners of type "' + type + '" added. '
|
+ 'leak detected. " + eventList.length + " listeners of type "' + type + '" added. '
|
||||||
+ 'Use emitter.setMaxListeners() to increase limit.'
|
+ 'Use emitter.setMaxListeners() to increase limit.'
|
||||||
);
|
);
|
||||||
|
|
Ładowanie…
Reference in New Issue