diff options
author | XadillaX <i@2333.moe> | 2021-05-31 12:00:46 +0300 |
---|---|---|
committer | XadillaX <i@2333.moe> | 2021-06-04 09:33:59 +0300 |
commit | fc4b9c1d0752e750e21a4ee7703a17fa67bfd95b (patch) | |
tree | 292b110298457bf9407876bb087c521f97d36598 /lib | |
parent | e7f941c1614ae0cc4c0022aefea130133afac612 (diff) |
child_process: allow `options.cwd` receive a URL
PR-URL: https://github.com/nodejs/node/pull/38862
Fixes: https://github.com/nodejs/node/issues/38861
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/child_process.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/child_process.js b/lib/child_process.js index 26e1bb33d0c..e3691639a9f 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -71,6 +71,7 @@ const { ERR_OUT_OF_RANGE, } = errorCodes; const { clearTimeout, setTimeout } = require('timers'); +const { getValidatedPath } = require('internal/fs/utils'); const { isInt32, validateAbortSignal, @@ -450,9 +451,11 @@ function normalizeSpawnArguments(file, args, options) { else validateObject(options, 'options'); + let cwd = options.cwd; + // Validate the cwd, if present. - if (options.cwd != null) { - validateString(options.cwd, 'options.cwd'); + if (cwd != null) { + cwd = getValidatedPath(cwd, 'options.cwd'); } // Validate detached, if present. @@ -577,11 +580,12 @@ function normalizeSpawnArguments(file, args, options) { // Make a shallow copy so we don't clobber the user's options object. ...options, args, + cwd, detached: !!options.detached, envPairs, file, windowsHide: !!options.windowsHide, - windowsVerbatimArguments: !!windowsVerbatimArguments + windowsVerbatimArguments: !!windowsVerbatimArguments, }; } |