From 21942bb0d34004f378721851a9acd0d51cd562d5 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Thu, 20 Jun 2019 10:00:00 +0200 Subject: [PATCH 1/2] Rename `stdio()` to `normalizeStdio()` --- index.js | 6 +++--- lib/stdio.js | 6 +++--- test/stdio.js | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index a7230cbe41..ccfe7e3dd8 100644 --- a/index.js +++ b/index.js @@ -11,7 +11,7 @@ const getStream = require('get-stream'); const mergeStream = require('merge-stream'); const pFinally = require('p-finally'); const onExit = require('signal-exit'); -const stdio = require('./lib/stdio'); +const normalizeStdio = require('./lib/stdio'); const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100; const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5; @@ -51,7 +51,7 @@ const handleArgs = (file, args, options = {}) => { }); } - options.stdio = stdio(options); + options.stdio = normalizeStdio(options); if (process.platform === 'win32' && path.basename(file, '.exe') === 'cmd') { // #116 @@ -529,7 +529,7 @@ module.exports.node = (scriptPath, args, options = {}) => { args = []; } - const stdioOption = stdio.node(options); + const stdioOption = normalizeStdio.node(options); const {nodePath = process.execPath, nodeOptions = process.execArgv} = options; diff --git a/lib/stdio.js b/lib/stdio.js index 310d5b485f..66b5c94a0d 100644 --- a/lib/stdio.js +++ b/lib/stdio.js @@ -3,7 +3,7 @@ const aliases = ['stdin', 'stdout', 'stderr']; const hasAlias = opts => aliases.some(alias => opts[alias] !== undefined); -const stdio = opts => { +const normalizeStdio = opts => { if (!opts) { return; } @@ -30,11 +30,11 @@ const stdio = opts => { return Array.from({length}, (value, index) => stdio[index]); }; -module.exports = stdio; +module.exports = normalizeStdio; // `ipc` is pushed unless it is already present module.exports.node = opts => { - const stdioOption = stdio(opts); + const stdioOption = normalizeStdio(opts); if (stdioOption === 'ipc') { return 'ipc'; diff --git a/test/stdio.js b/test/stdio.js index 153ca613b8..a7003f9fbf 100644 --- a/test/stdio.js +++ b/test/stdio.js @@ -1,11 +1,11 @@ import util from 'util'; import test from 'ava'; -import stdio from '../lib/stdio'; +import normalizeStdio from '../lib/stdio'; const macro = (t, input, expected, func) => { if (expected instanceof Error) { t.throws(() => { - stdio(input); + normalizeStdio(input); }, expected.message); return; } @@ -15,7 +15,7 @@ const macro = (t, input, expected, func) => { const macroTitle = name => (title, input) => `${name} ${(util.inspect(input))}`; -const stdioMacro = (...args) => macro(...args, stdio); +const stdioMacro = (...args) => macro(...args, normalizeStdio); stdioMacro.title = macroTitle('execa()'); test(stdioMacro, undefined, undefined); @@ -47,7 +47,7 @@ test(stdioMacro, {stdin: 'inherit', stdio: ['pipe']}, new Error('It\'s not possi 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); +const forkMacro = (...args) => macro(...args, normalizeStdio.node); forkMacro.title = macroTitle('execa.fork()'); test(forkMacro, undefined, [undefined, undefined, undefined, 'ipc']); From f4442d913e8572def958464f3fb481aad240a0a7 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Thu, 20 Jun 2019 10:00:00 +0200 Subject: [PATCH 2/2] Rename stdioOption to stdio --- lib/stdio.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/stdio.js b/lib/stdio.js index 66b5c94a0d..6344d24fca 100644 --- a/lib/stdio.js +++ b/lib/stdio.js @@ -34,19 +34,19 @@ module.exports = normalizeStdio; // `ipc` is pushed unless it is already present module.exports.node = opts => { - const stdioOption = normalizeStdio(opts); + const stdio = normalizeStdio(opts); - if (stdioOption === 'ipc') { + if (stdio === 'ipc') { return 'ipc'; } - if (stdioOption === undefined || typeof stdioOption === 'string') { - return [stdioOption, stdioOption, stdioOption, 'ipc']; + if (stdio === undefined || typeof stdio === 'string') { + return [stdio, stdio, stdio, 'ipc']; } - if (stdioOption.includes('ipc')) { - return stdioOption; + if (stdio.includes('ipc')) { + return stdio; } - return [...stdioOption, 'ipc']; + return [...stdio, 'ipc']; };