Skip to content

Commit e87cd45

Browse files
Ayase-252targos
authored andcommitted
child_process: refactor to use validateBoolean
PR-URL: #38927 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Zijian Liu <lxxyxzj@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 651c58b commit e87cd45

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

lib/child_process.js

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ const { getValidatedPath } = require('internal/fs/utils');
7575
const {
7676
isInt32,
7777
validateAbortSignal,
78+
validateBoolean,
7879
validateObject,
7980
validateString,
8081
} = require('internal/validators');
@@ -459,10 +460,8 @@ function normalizeSpawnArguments(file, args, options) {
459460
}
460461

461462
// Validate detached, if present.
462-
if (options.detached != null &&
463-
typeof options.detached !== 'boolean') {
464-
throw new ERR_INVALID_ARG_TYPE('options.detached',
465-
'boolean', options.detached);
463+
if (options.detached != null) {
464+
validateBoolean(options.detached, 'options.detached');
466465
}
467466

468467
// Validate the uid, if present.
@@ -489,19 +488,15 @@ function normalizeSpawnArguments(file, args, options) {
489488
}
490489

491490
// Validate windowsHide, if present.
492-
if (options.windowsHide != null &&
493-
typeof options.windowsHide !== 'boolean') {
494-
throw new ERR_INVALID_ARG_TYPE('options.windowsHide',
495-
'boolean', options.windowsHide);
491+
if (options.windowsHide != null) {
492+
validateBoolean(options.windowsHide, 'options.windowsHide');
496493
}
497494

498495
// Validate windowsVerbatimArguments, if present.
499496
let { windowsVerbatimArguments } = options;
500-
if (windowsVerbatimArguments != null &&
501-
typeof windowsVerbatimArguments !== 'boolean') {
502-
throw new ERR_INVALID_ARG_TYPE('options.windowsVerbatimArguments',
503-
'boolean',
504-
windowsVerbatimArguments);
497+
if (windowsVerbatimArguments != null) {
498+
validateBoolean(windowsVerbatimArguments,
499+
'options.windowsVerbatimArguments');
505500
}
506501

507502
if (options.shell) {

0 commit comments

Comments
 (0)