Skip to content

Commit 25e2330

Browse files
committed
ignore npm exit
1 parent 5a2f700 commit 25e2330

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

bin/create-net.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const https = require('https');
44
const fs = require('fs');
55
const path = require('path');
6-
const { execSync } = require('child_process');
6+
const { spawnSync } = require('child_process');
77
const AdmZip = require('adm-zip');
88

99
// Parse command line arguments
@@ -312,13 +312,17 @@ function runNpmInstall(dirPath) {
312312
// Check if current directory has package.json
313313
if (items.includes('package.json')) {
314314
console.log(`Running npm install in ${dirPath}...`);
315-
try {
316-
execSync('npm install', {
317-
cwd: dirPath,
318-
stdio: 'inherit'
319-
});
320-
} catch (err) {
321-
console.error(`Warning: npm install failed in ${dirPath}`);
315+
// Use spawnSync instead of execSync to have better control over exit codes
316+
// npm returns exit code 1 for vulnerabilities, which shouldn't fail the script
317+
const result = spawnSync('npm', ['install'], {
318+
cwd: dirPath,
319+
stdio: 'inherit',
320+
shell: true
321+
});
322+
323+
// Only warn on actual failures (exit codes > 1), not on vulnerabilities (exit code 1)
324+
if (result.status !== null && result.status > 1) {
325+
console.error(`Warning: npm install failed in ${dirPath} with exit code ${result.status}`);
322326
}
323327
}
324328

0 commit comments

Comments
 (0)