Skip to content

Commit 70506f2

Browse files
guangyuexuDevtools-frontend LUCI CQ
authored andcommitted
update spawnSync for npm run test
In windows platform, the `spawnSync` will fail without explicitly invoking the `cmd.exe` to run a bat script. When the `spawnSync` failed, the `stdout` and `stderr` will be undefined. Added protection for them. Bug: 490139146 Change-Id: Ib744a36c9a81a2bf5b20dae3689acc6b057cad05 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7640129 Commit-Queue: Guangyue Xu <guangyue.xu@microsoft.com> Reviewed-by: Nikolay Vitkov <nvitkov@chromium.org> Reviewed-by: Simon Zünd <szuend@chromium.org>
1 parent 9501c91 commit 70506f2

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

scripts/run_on_target.mjs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,20 @@ if (
8181
}
8282

8383
if (!skipNinja) {
84+
const ninjaCommand = process.platform === 'win32' ? process.env.ComSpec ?? 'cmd.exe' : 'autoninja';
85+
const ninjaArgs = process.platform === 'win32' ? ['/c', 'autoninja', '-C', cwd, script] : ['-C', cwd, script];
8486
const { error, status, stdout, stderr } = childProcess.spawnSync(
85-
'autoninja',
86-
['-C', cwd, script],
87+
ninjaCommand,
88+
ninjaArgs,
8789
{ stdio: debug ? 'inherit' : 'pipe', cwd: sourceRoot },
8890
);
8991
if (status || error) {
90-
console.log(stdout.toString());
91-
console.log(stderr.toString());
92+
if (stdout) {
93+
console.log(stdout.toString());
94+
}
95+
if (stderr) {
96+
console.log(stderr.toString());
97+
}
9298
if (error) {
9399
console.error(error);
94100
}

0 commit comments

Comments
 (0)