fix(release): sh() 容错 stdio:'inherit' 的 null 返回(发版首跑即炸)

This commit is contained in:
jkooe committed 2026-10-05 00:13:45 +08:00
1 parent 6faf807108
commit 1c26dc4e3f
1 file changed
+6 -2
+6 -2
View File
@@ -27,8 +27,12 @@ const arg = argv.find((a) => !a.startsWith('--'));
const dryRun = flags.has('--dry-run');
const publish = !flags.has('--no-publish');
const sh = (cmd, args, opts = {}) =>
execFileSync(cmd, args, { cwd: root, encoding: 'utf8', ...opts }).toString().trim();
// ⚠️ stdio:'inherit' 时 execFileSync 返回 null(不捕获输出)→ 必须容错,
// 否则 build/pack 这类「继承输出」的调用会直接 TypeError(真机踩过)
const sh = (cmd, args, opts = {}) => {
const out = execFileSync(cmd, args, { cwd: root, encoding: 'utf8', ...opts });
return out === null || out === undefined ? '' : String(out).trim();
};
function fail(msg) {
console.error(`✗ ${msg}`);