Skip to content

Commit b48b737

Browse files
Refactor npm audit error handling to throw errors instead of silently finish
1 parent 12bb2a6 commit b48b737

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

make-util.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,20 +180,20 @@ function performNpmAudit(taskPath) {
180180
shell: true
181181
});
182182

183-
if (auditResult.error) {
183+
if (auditResult.status) {
184184
console.log(`\x1b[A\x1b[K❌ npm audit failed because the build task at "${taskPath}" has vulnerable dependencies.`);
185185
console.log('👉 Please see details by running the command');
186186
console.log(`\tnpm audit --prefix ${taskPath}`);
187187
console.log('or execute the command with --BypassNpmAudit argument to skip the auditing');
188-
console.log(`\tnode make.js --build --task ${args.task} --BypassNpmAudit`);
189-
process.exit(1);
188+
console.log(`\tnode make.js build --task ${args.task} --BypassNpmAudit`);
189+
throw new Error(`npm audit failed with exit code: ${auditResult.status}`);
190190
} else {
191191
console.log('\x1b[A\x1b[K✅ npm audit completed successfully.');
192192
}
193193
} catch (error) {
194194
console.error('\x1b[A\x1b[K❌ "performNpmAudit" failed.');
195195
console.error(error.message);
196-
process.exit(1);
196+
throw error;
197197
}
198198
}
199199

@@ -916,10 +916,10 @@ var validateUuid = function (uuid) {
916916

917917
try {
918918
const uuidLib = require('node-uuid');
919-
919+
920920
// node-uuid.parse() returns a buffer if valid, throws if invalid
921921
var parsed = uuidLib.parse(uuid);
922-
922+
923923
// If parse succeeds and returns a 16-byte buffer, the UUID is valid
924924
return parsed && parsed.length === 16;
925925
} catch (error) {
@@ -1902,7 +1902,7 @@ var processGeneratedTasks = function (baseConfigToolPath, taskList, makeOptions,
19021902
}
19031903
if (useSemverBuildConfig === true || useSemverBuildConfig === 'true') {
19041904
writeUpdateArg += " --use-semver-build-config";
1905-
}
1905+
}
19061906

19071907
var debugAgentDirArg = "";
19081908
if(debugAgentDir) {

0 commit comments

Comments
 (0)