v1.18.x
barisusakli 8 years ago
parent c14a31644b
commit b37d52c089

@ -8,7 +8,9 @@ module.exports = function (Plugins) {
'filter:user.custom_fields': null, // remove in v1.1.0 'filter:user.custom_fields': null, // remove in v1.1.0
'filter:post.save': 'filter:post.create', 'filter:post.save': 'filter:post.create',
'filter:user.profileLinks': 'filter:user.profileMenu', 'filter:user.profileLinks': 'filter:user.profileMenu',
'action:post.flag': 'action:flag.create' 'action:post.flag': 'action:flag.create',
'action:plugin.activate': null,
'action:plugin.install': null
}; };
/* /*
`data` is an object consisting of (* is required): `data` is an object consisting of (* is required):

@ -50,8 +50,11 @@ module.exports = function (Plugins) {
}, },
function (next) { function (next) {
meta.reloadRequired = true; meta.reloadRequired = true;
Plugins.fireHook(isActive ? 'action:plugin.deactivate' : 'action:plugin.activate', {id: id}); if (isActive) {
next(); Plugins.fireHook('action:plugin.deactivate', {id: id});
}
setImmediate(next);
} }
], function (err) { ], function (err) {
if (err) { if (err) {
@ -68,7 +71,6 @@ module.exports = function (Plugins) {
}; };
function toggleInstall(id, version, callback) { function toggleInstall(id, version, callback) {
var type;
var installed; var installed;
async.waterfall([ async.waterfall([
function (next) { function (next) {
@ -76,7 +78,6 @@ module.exports = function (Plugins) {
}, },
function (_installed, next) { function (_installed, next) {
installed = _installed; installed = _installed;
type = installed ? 'uninstall' : 'install';
Plugins.isActive(id, next); Plugins.isActive(id, next);
}, },
function (active, next) { function (active, next) {
@ -86,17 +87,20 @@ module.exports = function (Plugins) {
}); });
return; return;
} }
next(); setImmediate(next);
}, },
function (next) { function (next) {
runNpmCommand(type, id, version || 'latest', next); runNpmCommand(installed ? 'uninstall' : 'install', id, version || 'latest', next);
}, },
function (next) { function (next) {
Plugins.get(id, next); Plugins.get(id, next);
}, },
function (pluginData, next) { function (pluginData, next) {
Plugins.fireHook('action:plugin.' + type, {id: id, version: version}); if (installed) {
next(null, pluginData); Plugins.fireHook('action:plugin.uninstall', {id: id, version: version});
}
setImmediate(next, null, pluginData);
} }
], callback); ], callback);
} }

@ -88,7 +88,7 @@ module.exports = function (Plugins) {
}, },
function (next) { function (next) {
mapClientModules(pluginData, next); mapClientModules(pluginData, next);
}, }
], function (err) { ], function (err) {
if (err) { if (err) {
winston.verbose('[plugins] Could not load plugin : ' + pluginData.id); winston.verbose('[plugins] Could not load plugin : ' + pluginData.id);

Loading…
Cancel
Save