Catch all errors in pluginfw/installer.js
parent
e8bae61cf5
commit
9109bd206e
|
@ -6,7 +6,7 @@ var npmIsLoaded = false;
|
||||||
var withNpm = function (npmfn) {
|
var withNpm = function (npmfn) {
|
||||||
if(npmIsLoaded) return npmfn();
|
if(npmIsLoaded) return npmfn();
|
||||||
npm.load({}, function (er) {
|
npm.load({}, function (er) {
|
||||||
if (er) return cb(er);
|
if (er) return npmfn(er);
|
||||||
npmIsLoaded = true;
|
npmIsLoaded = true;
|
||||||
npm.on("log", function (message) {
|
npm.on("log", function (message) {
|
||||||
console.log('npm: ',message)
|
console.log('npm: ',message)
|
||||||
|
@ -16,7 +16,8 @@ var withNpm = function (npmfn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.uninstall = function(plugin_name, cb) {
|
exports.uninstall = function(plugin_name, cb) {
|
||||||
withNpm(function () {
|
withNpm(function (er) {
|
||||||
|
if (er) return cb && cb(er);
|
||||||
npm.commands.uninstall([plugin_name], function (er) {
|
npm.commands.uninstall([plugin_name], function (er) {
|
||||||
if (er) return cb && cb(er);
|
if (er) return cb && cb(er);
|
||||||
hooks.aCallAll("pluginUninstall", {plugin_name: plugin_name}, function (er, data) {
|
hooks.aCallAll("pluginUninstall", {plugin_name: plugin_name}, function (er, data) {
|
||||||
|
@ -30,16 +31,17 @@ exports.uninstall = function(plugin_name, cb) {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.install = function(plugin_name, cb) {
|
exports.install = function(plugin_name, cb) {
|
||||||
withNpm(function () {
|
withNpm(function (er) {
|
||||||
npm.commands.install([plugin_name], function (er) {
|
if (er) return cb && cb(er);
|
||||||
if (er) return cb && cb(er);
|
npm.commands.install([plugin_name], function (er) {
|
||||||
hooks.aCallAll("pluginInstall", {plugin_name: plugin_name}, function (er, data) {
|
if (er) return cb && cb(er);
|
||||||
if (er) return cb(er);
|
hooks.aCallAll("pluginInstall", {plugin_name: plugin_name}, function (er, data) {
|
||||||
plugins.update(cb);
|
if (er) return cb(er);
|
||||||
cb && cb();
|
plugins.update(cb);
|
||||||
hooks.aCallAll("restartServer", {}, function () {});
|
cb && cb();
|
||||||
});
|
hooks.aCallAll("restartServer", {}, function () {});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -47,7 +49,8 @@ exports.availablePlugins = null;
|
||||||
var cacheTimestamp = 0;
|
var cacheTimestamp = 0;
|
||||||
|
|
||||||
exports.getAvailablePlugins = function(maxCacheAge, cb) {
|
exports.getAvailablePlugins = function(maxCacheAge, cb) {
|
||||||
withNpm(function () {
|
withNpm(function (er) {
|
||||||
|
if (er) return cb && cb(er);
|
||||||
if(exports.availablePlugins && maxCacheAge && Math.round(+new Date/1000)-cacheTimestamp <= maxCacheAge) {
|
if(exports.availablePlugins && maxCacheAge && Math.round(+new Date/1000)-cacheTimestamp <= maxCacheAge) {
|
||||||
return cb && cb(null, exports.availablePlugins)
|
return cb && cb(null, exports.availablePlugins)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue