Skip to content

Commit

Permalink
Fix non-executable execution with input option (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanis Benson authored and sindresorhus committed May 7, 2019
1 parent 075faf3 commit a428249
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Expand Up @@ -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;
}

Expand Down
4 changes: 4 additions & 0 deletions test.js
Expand Up @@ -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 => {
Expand Down

0 comments on commit a428249

Please sign in to comment.