mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-09 15:35:47 +01:00
action:plugin.install and uninstall
This commit is contained in:
@@ -64,7 +64,7 @@ module.exports = function(Plugins) {
|
|||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
var type = installed ? 'uninstall' : 'install';
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function(next) {
|
function(next) {
|
||||||
Plugins.isActive(id, next);
|
Plugins.isActive(id, next);
|
||||||
@@ -82,10 +82,14 @@ module.exports = function(Plugins) {
|
|||||||
npm.load({}, next);
|
npm.load({}, next);
|
||||||
},
|
},
|
||||||
function(res, next) {
|
function(res, next) {
|
||||||
npm.commands[installed ? 'uninstall' : 'install'](installed ? id : [id + '@' + (version || 'latest')], next);
|
npm.commands[type](installed ? id : [id + '@' + (version || 'latest')], next);
|
||||||
}
|
}
|
||||||
], function(err) {
|
], function(err) {
|
||||||
callback(err, {id: id, installed: !installed});
|
if (err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
plugins.fireHook('action:plugin.' + type, id);
|
||||||
|
callback(null, {id: id, installed: !installed});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user