diff --git a/index.js b/index.js index bb635fadf8..6261c3abfd 100644 --- a/index.js +++ b/index.js @@ -107,7 +107,8 @@ function handleArgs(command, args, options = {}) { } function handleInput(spawned, input) { - if (input === undefined) { + // Checking for stdin is workaround for https://github.com/nodejs/node/issues/26852 on Node.js 10 and 12 + if (input === undefined || spawned.stdin === undefined) { return; } diff --git a/test.js b/test.js index 2c7e017dd1..abbf7d77c8 100644 --- a/test.js +++ b/test.js @@ -336,6 +336,10 @@ if (process.platform !== 'win32') { const cp = execa('non-executable'); await t.throwsAsync(cp); }); + + test('execa() rejects with correct error and doesn\'t throw if running non-executable with input', async t => { + await t.throwsAsync(execa('non-executable', {input: 'Hey!'}), /EACCES/); + }); } test('error.killed is true if process was killed directly', async t => {