Skip to content

Commit f9f82d5

Browse files
fix(ci): move deps:tree to script file to fix publish failure
The inline node -e command had backticks that sh on Linux interpreted as command substitution, causing `sh: 1: n+t+: not found`. Also, npm ls exits non-zero on ELSPROBLEMS (version mismatches in optional platform-specific deps), which made execSync throw during publish. Fix: move to scripts/gen-deps.cjs with try/catch to handle npm ls failures gracefully, and use --omit=dev to exclude devDependencies.
1 parent ae286d4 commit f9f82d5

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"lint:fix": "biome check --write src/ tests/",
3131
"format": "biome format --write src/ tests/",
3232
"prepare": "npm run build:wasm && husky && npm run deps:tree",
33-
"deps:tree": "node -e \"const{execSync}=require('child_process');const t=execSync('npm ls --all --omit=dev',{encoding:'utf8'});require('fs').writeFileSync('DEPENDENCIES.md','# Dependencies\\n\\n```\\n'+t+'```\\n')\"",
33+
"deps:tree": "node scripts/gen-deps.cjs",
3434
"release": "commit-and-tag-version",
3535
"release:dry-run": "commit-and-tag-version --dry-run",
3636
"version": "node scripts/sync-native-versions.js && git add package.json",

scripts/gen-deps.cjs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const { execSync } = require('child_process');
2+
const fs = require('fs');
3+
4+
try {
5+
const tree = execSync('npm ls --all --omit=dev', { encoding: 'utf8' });
6+
fs.writeFileSync(
7+
'DEPENDENCIES.md',
8+
'# Dependencies\n\n```\n' + tree + '```\n',
9+
);
10+
} catch (err) {
11+
// npm ls exits non-zero on ELSPROBLEMS (version mismatches in optional deps).
12+
// If stdout still has content, write it; otherwise skip silently.
13+
if (err.stdout) {
14+
fs.writeFileSync(
15+
'DEPENDENCIES.md',
16+
'# Dependencies\n\n```\n' + err.stdout + '```\n',
17+
);
18+
} else {
19+
console.warn('deps:tree skipped —', err.message);
20+
}
21+
}

0 commit comments

Comments
 (0)