From de1d7f75a89f9a7edb448e74bf08a9b01c6cb41d Mon Sep 17 00:00:00 2001 From: ehmicky Date: Wed, 19 Jun 2019 10:00:00 +0200 Subject: [PATCH] Do not allow `stdin: 0` combined with `stdio` --- lib/stdio.js | 2 +- test/stdio.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/stdio.js b/lib/stdio.js index bef74aeead..fcc3a15128 100644 --- a/lib/stdio.js +++ b/lib/stdio.js @@ -1,7 +1,7 @@ 'use strict'; const aliases = ['stdin', 'stdout', 'stderr']; -const hasAlias = opts => aliases.some(alias => Boolean(opts[alias])); +const hasAlias = opts => aliases.some(alias => opts[alias] !== undefined); const stdio = opts => { if (!opts) { diff --git a/test/stdio.js b/test/stdio.js index 59cc648903..3aa5d37730 100644 --- a/test/stdio.js +++ b/test/stdio.js @@ -45,6 +45,7 @@ test(stdioMacro, {stdio: {foo: 'bar'}}, new TypeError('Expected `stdio` to be of test(stdioMacro, {stdin: 'inherit', stdio: 'pipe'}, new Error('It\'s not possible to provide `stdio` in combination with one of `stdin`, `stdout`, `stderr`')); test(stdioMacro, {stdin: 'inherit', stdio: ['pipe']}, new Error('It\'s not possible to provide `stdio` in combination with one of `stdin`, `stdout`, `stderr`')); test(stdioMacro, {stdin: 'inherit', stdio: [undefined, 'pipe']}, new Error('It\'s not possible to provide `stdio` in combination with one of `stdin`, `stdout`, `stderr`')); +test(stdioMacro, {stdin: 0, stdio: 'pipe'}, new Error('It\'s not possible to provide `stdio` in combination with one of `stdin`, `stdout`, `stderr`')); const forkMacro = (...args) => macro(...args, stdio.node); forkMacro.title = macroTitle('execa.fork()');