Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

Commit abf20d1

Browse files
committed
feat(core): spawn use stderr
1 parent 5b1af92 commit abf20d1

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

packages/framework-core/src/plugin-manager/pkg-install.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export function install(
2020
// 支持node8
2121
return spawnPromise('npm', [...args, ...packageList, ...npmOptions], {
2222
cwd: options?.cwd || process.cwd(),
23-
stdio: undefined,
2423
});
2524
}
2625

packages/framework-core/src/utils/spawn.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export async function spawnPromise(
1919
Object.assign(
2020
{
2121
shell: true,
22-
stdio: 'inherit',
22+
// stderr 使用 process.stderr 用于收集错误
23+
stdio: ['inherit', 'inherit', 'pipe'],
2324
},
2425
options
2526
)
@@ -32,7 +33,10 @@ export async function spawnPromise(
3233
cm.stderr?.on('data', (data) => {
3334
stderr += data;
3435
});
36+
3537
cm.on('error', reject);
36-
cm.on('close', (code) => (code === 0 ? resolve(stdout) : reject(stderr)));
38+
cm.on('close', (code) => {
39+
code === 0 ? resolve(stdout) : reject(new Error(stderr || String(code)));
40+
});
3741
});
3842
}

0 commit comments

Comments
 (0)