Allow preInstall hook to return false to skip npm install

This commit is contained in:
Nick O'Leary
2021-04-19 20:29:30 +01:00
parent d2432716ea
commit b4a03a56b4
4 changed files with 38 additions and 8 deletions

View File

@@ -196,11 +196,15 @@ async function installModule(moduleDetails) {
"version": moduleDetails.version,
"dir": installDir,
}
return hooks.trigger("preInstall", triggerPayload).then(() => {
return hooks.trigger("preInstall", triggerPayload).then((result) => {
// preInstall passed
// - run install
log.trace(NPM_COMMAND + JSON.stringify(args));
return exec.run(NPM_COMMAND, args, { cwd: installDir },true)
if (result !== false) {
log.trace(NPM_COMMAND + JSON.stringify(args));
return exec.run(NPM_COMMAND, args, { cwd: installDir },true)
} else {
log.trace("skipping npm install");
}
}).then(() => {
return hooks.trigger("postInstall", triggerPayload)
}).then(() => {

View File

@@ -178,11 +178,15 @@ async function installModule(module,version,url) {
"isUpgrade": isUpgrade
}
return hooks.trigger("preInstall", triggerPayload).then(() => {
return hooks.trigger("preInstall", triggerPayload).then((result) => {
// preInstall passed
// - run install
log.trace(npmCommand + JSON.stringify(args));
return exec.run(npmCommand,args,{ cwd: installDir}, true)
if (result !== false) {
log.trace(npmCommand + JSON.stringify(args));
return exec.run(npmCommand,args,{ cwd: installDir}, true)
} else {
log.trace("skipping npm install");
}
}).then(() => {
return hooks.trigger("postInstall", triggerPayload)
}).then(() => {