Skip to content

Commit 28e2c37

Browse files
committed
child_process: rename _validateStdtio to getValidStdio
The name indicated only validation while it did much more and it returned a different value to the callee function. The underscore was also not necessary as the function is internal one way or the other. PR-URL: #26809 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 9e8c9be commit 28e2c37

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

lib/child_process.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const {
4141
const { validateString, isInt32 } = require('internal/validators');
4242
const child_process = require('internal/child_process');
4343
const {
44-
_validateStdio,
44+
getValidStdio,
4545
setupChannel,
4646
ChildProcess
4747
} = child_process;
@@ -577,7 +577,7 @@ function spawnSync(file, args, options) {
577577
// Validate and translate the kill signal, if present.
578578
options.killSignal = sanitizeKillSignal(options.killSignal);
579579

580-
options.stdio = _validateStdio(options.stdio || 'pipe', true).stdio;
580+
options.stdio = getValidStdio(options.stdio || 'pipe', true).stdio;
581581

582582
if (options.input) {
583583
var stdin = options.stdio[0] = { ...options.stdio[0] };

lib/internal/child_process.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ ChildProcess.prototype.spawn = function(options) {
315315
// If no `stdio` option was given - use default
316316
var stdio = options.stdio || 'pipe';
317317

318-
stdio = _validateStdio(stdio, false);
318+
stdio = getValidStdio(stdio, false);
319319

320320
ipc = stdio.ipc;
321321
ipcFd = stdio.ipcFd;
@@ -873,7 +873,7 @@ function isInternal(message) {
873873

874874
function nop() { }
875875

876-
function _validateStdio(stdio, sync) {
876+
function getValidStdio(stdio, sync) {
877877
var ipc;
878878
var ipcFd;
879879

@@ -1028,6 +1028,6 @@ function spawnSync(opts) {
10281028
module.exports = {
10291029
ChildProcess,
10301030
setupChannel,
1031-
_validateStdio,
1031+
getValidStdio,
10321032
spawnSync
10331033
};

test/parallel/test-child-process-validate-stdio.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33

44
const common = require('../common');
55
const assert = require('assert');
6-
const _validateStdio = require('internal/child_process')._validateStdio;
6+
const getValidStdio = require('internal/child_process').getValidStdio;
77

88
const expectedError =
99
common.expectsError({ code: 'ERR_INVALID_OPT_VALUE', type: TypeError }, 2);
1010

1111
// Should throw if string and not ignore, pipe, or inherit
12-
assert.throws(() => _validateStdio('foo'), expectedError);
12+
assert.throws(() => getValidStdio('foo'), expectedError);
1313

1414
// Should throw if not a string or array
15-
assert.throws(() => _validateStdio(600), expectedError);
15+
assert.throws(() => getValidStdio(600), expectedError);
1616

1717
// Should populate stdio with undefined if len < 3
1818
{
1919
const stdio1 = [];
20-
const result = _validateStdio(stdio1, false);
20+
const result = getValidStdio(stdio1, false);
2121
assert.strictEqual(stdio1.length, 3);
2222
assert.strictEqual(result.hasOwnProperty('stdio'), true);
2323
assert.strictEqual(result.hasOwnProperty('ipc'), true);
@@ -26,14 +26,14 @@ assert.throws(() => _validateStdio(600), expectedError);
2626

2727
// Should throw if stdio has ipc and sync is true
2828
const stdio2 = ['ipc', 'ipc', 'ipc'];
29-
common.expectsError(() => _validateStdio(stdio2, true),
29+
common.expectsError(() => getValidStdio(stdio2, true),
3030
{ code: 'ERR_IPC_SYNC_FORK', type: Error }
3131
);
3232

3333

3434
if (common.isMainThread) {
3535
const stdio3 = [process.stdin, process.stdout, process.stderr];
36-
const result = _validateStdio(stdio3, false);
36+
const result = getValidStdio(stdio3, false);
3737
assert.deepStrictEqual(result, {
3838
stdio: [
3939
{ type: 'fd', fd: 0 },

0 commit comments

Comments
 (0)