diff options
author | XadillaX <i@2333.moe> | 2021-05-31 12:00:46 +0300 |
---|---|---|
committer | Michaƫl Zasso <targos@protonmail.com> | 2021-06-11 08:24:52 +0300 |
commit | 69fa9e16e9593618a068213a1afe38883bcff5be (patch) | |
tree | a4b67c8d0a4fc43043446ae0a3e92dc5d55092ca /lib | |
parent | 07065650970307850dfb26fa72800e891c6de922 (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, }; } |