1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Pass npm args to preUninstall hook to be consistent with preInstall

This commit is contained in:
Nick O'Leary 2021-04-27 17:32:18 +01:00
parent a0c09fc617
commit 9f2a2b9869
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -446,17 +446,22 @@ function uninstallModule(module) {
var list = registry.removeModule(module);
log.info(log._("server.install.uninstalling",{name:module}));
var args = ['remove','--no-audit','--no-update-notifier','--no-fund','--save',module];
let triggerPayload = {
"module": module,
"dir": installDir,
"args": ['--no-audit','--no-update-notifier','--no-fund','--save']
}
return hooks.trigger("preUninstall", triggerPayload).then(() => {
return hooks.trigger("preUninstall", triggerPayload).then((result) => {
// preUninstall passed
// - run uninstall
log.trace(npmCommand + JSON.stringify(args));
return exec.run(npmCommand,args,{ cwd: installDir}, true)
if (result !== false) {
let extraArgs = triggerPayload.args || [];
let args = ['remove', ...extraArgs, module]
log.trace(npmCommand + JSON.stringify(args));
return exec.run(npmCommand,args,{ cwd: installDir}, true)
} else {
log.trace("skipping npm uninstall");
}
}).then(() => {
log.info(log._("server.install.uninstalled",{name:module}));
reportRemovedModules(list);