Skip to content

Commit fc2b1ec

Browse files
Ayase-252richardlau
authored andcommitted
child_process: refactor to use validateBoolean
PR-URL: #38927 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Khaidi Chu <[email protected]> Reviewed-By: Zijian Liu <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 49a0006 commit fc2b1ec

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
@@ -62,6 +62,7 @@ const {
6262
validateString,
6363
isInt32,
6464
validateAbortSignal,
65+
validateBoolean,
6566
} = require('internal/validators');
6667
const child_process = require('internal/child_process');
6768
const {
@@ -463,10 +464,8 @@ function normalizeSpawnArguments(file, args, options) {
463464
}
464465

465466
// Validate detached, if present.
466-
if (options.detached != null &&
467-
typeof options.detached !== 'boolean') {
468-
throw new ERR_INVALID_ARG_TYPE('options.detached',
469-
'boolean', options.detached);
467+
if (options.detached != null) {
468+
validateBoolean(options.detached, 'options.detached');
470469
}
471470

472471
// Validate the uid, if present.
@@ -494,19 +493,15 @@ function normalizeSpawnArguments(file, args, options) {
494493
}
495494

496495
// Validate windowsHide, if present.
497-
if (options.windowsHide != null &&
498-
typeof options.windowsHide !== 'boolean') {
499-
throw new ERR_INVALID_ARG_TYPE('options.windowsHide',
500-
'boolean', options.windowsHide);
496+
if (options.windowsHide != null) {
497+
validateBoolean(options.windowsHide, 'options.windowsHide');
501498
}
502499

503500
// Validate windowsVerbatimArguments, if present.
504501
let { windowsVerbatimArguments } = options;
505-
if (windowsVerbatimArguments != null &&
506-
typeof windowsVerbatimArguments !== 'boolean') {
507-
throw new ERR_INVALID_ARG_TYPE('options.windowsVerbatimArguments',
508-
'boolean',
509-
windowsVerbatimArguments);
502+
if (windowsVerbatimArguments != null) {
503+
validateBoolean(windowsVerbatimArguments,
504+
'options.windowsVerbatimArguments');
510505
}
511506

512507
if (options.shell) {

0 commit comments

Comments
 (0)