Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix non-executable execution with input option #212

Merged
merged 5 commits into from May 7, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -107,7 +107,7 @@ function handleArgs(command, args, options = {}) {
}

function handleInput(spawned, input) {
if (input === undefined) {
if (input === undefined || spawned.stdin === undefined) {
stroncium marked this conversation as resolved.
Show resolved Hide resolved
return;
}

Expand Down
6 changes: 6 additions & 0 deletions test.js
Expand Up @@ -336,6 +336,12 @@ 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(() => {
ehmicky marked this conversation as resolved.
Show resolved Hide resolved
return execa('non-executable', {input: 'Hey!'});
}, /EACCES/);
});
}

test('error.killed is true if process was killed directly', async t => {
Expand Down