Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/node_task_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ void ProcessRunner::Run() {
options_.cwd = cwd_.c_str();
if (int r = uv_spawn(loop_, &process_, &options_)) {
fprintf(stderr, "Error: %s\n", uv_strerror(r));
init_result_->exit_code_ = ExitCode::kGenericUserError;
return;
}

uv_run(loop_, UV_RUN_DEFAULT);
Expand Down
20 changes: 20 additions & 0 deletions test/parallel/test-node-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,26 @@ describe('node --run [command]', () => {
assert.strictEqual(child.code, 1);
});

it('returns an error when spawning the shell fails', {
skip: !common.isWindows,
}, async () => {
const env = { ...process.env };
for (const key of Object.keys(env)) {
if (key.toLowerCase() === 'comspec') {
delete env[key];
}
}
env.ComSpec = fixtures.path('run-script', 'non-existent-cmd.exe');

const child = await common.spawnPromisified(
process.execPath,
[ '--run', 'test'],
{ cwd: fixtures.path('run-script'), env },
);
assert.match(child.stderr, /^Error: /);
assert.strictEqual(child.code, 1);
});

it('adds node_modules/.bin to path', async () => {
const child = await common.spawnPromisified(
process.execPath,
Expand Down
Loading