node.js
This file
Path
lib/node.js
34 lines · 1.0 KiB · JavaScript
Last changed by
Merge `execPath` and `nodePath` options (#812)ehmickybefore adoptionfa04e3c
History of this fileTake it
Add `node` option (#804)ehmickybefore adoption663136b
line 1why, one step back1import {execPath, execArgv} from 'node:process';Merge `execPath` and `nodePath` options (#812)ehmickybefore adoptionfa04e3c
line 2why, one step back2import {basename, resolve} from 'node:path';Add `node` option (#804)ehmickybefore adoption663136b
lines 3–8why, one step back3import {safeNormalizeFileUrl} from './cwd.js';45export const handleNodeOption = (file, args, {6 node: shouldHandleNode = false,7 nodePath = execPath,8 nodeOptions = execArgv.filter(arg => !arg.startsWith('--inspect')),Merge `execPath` and `nodePath` options (#812)ehmickybefore adoptionfa04e3c
lines 9–10why, one step back9 cwd,10 execPath: formerNodePath,Add `node` option (#804)ehmickybefore adoption663136b
lines 11–12why, one step back11 ...options12}) => {Merge `execPath` and `nodePath` options (#812)ehmickybefore adoptionfa04e3c
lines 13–20why, one step back13 if (formerNodePath !== undefined) {14 throw new TypeError('The "execPath" option has been removed. Please use the "nodePath" option instead.');15 }1617 const normalizedNodePath = safeNormalizeFileUrl(nodePath, 'The "nodePath" option');18 const resolvedNodePath = resolve(cwd, normalizedNodePath);19 const newOptions = {...options, nodePath: resolvedNodePath, cwd};20Add `node` option (#804)ehmickybefore adoption663136b
line 21why, one step back21 if (!shouldHandleNode) {Merge `execPath` and `nodePath` options (#812)ehmickybefore adoptionfa04e3c
line 22why, one step back22 return [file, args, newOptions];Add `node` option (#804)ehmickybefore adoption663136b
lines 23–29why, one step back23 }2425 if (basename(file, '.exe') === 'node') {26 throw new TypeError('When the "node" option is true, the first argument does not need to be "node".');27 }2829 return [Merge `execPath` and `nodePath` options (#812)ehmickybefore adoptionfa04e3c
line 30why, one step back30 resolvedNodePath,Add `node` option (#804)ehmickybefore adoption663136b
line 31why, one step back31 [...nodeOptions, file, ...args],Merge `execPath` and `nodePath` options (#812)ehmickybefore adoptionfa04e3c
line 32why, one step back32 {ipc: true, ...newOptions, shell: false},Add `node` option (#804)ehmickybefore adoption663136b
lines 33–34why, one step back33 ];34};