Allow npm install args to be customised by preInstall trigger

This commit is contained in:
Nick O'Leary
2021-04-20 22:55:06 +01:00
parent b4a03a56b4
commit 250005ad16
4 changed files with 15 additions and 8 deletions

View File

@@ -190,16 +190,18 @@ async function installModule(moduleDetails) {
await ensureModuleDir();
var args = ["install", installSpec, "--production"];
let triggerPayload = {
"module": moduleDetails.module,
"version": moduleDetails.version,
"dir": installDir,
"args": ["--production"]
}
return hooks.trigger("preInstall", triggerPayload).then((result) => {
// preInstall passed
// - run install
if (result !== false) {
let extraArgs = triggerPayload.args || [];
let args = ['install', ...extraArgs, installSpec]
log.trace(NPM_COMMAND + JSON.stringify(args));
return exec.run(NPM_COMMAND, args, { cwd: installDir },true)
} else {