node.js
This file
Path
lib/node.js
24 lines · 689 bytes · JavaScript
Last changed by
Add `node` option (#804)ehmickybefore adoption663136b
History of this fileTake it
Add `node` option (#804)ehmickybefore adoption663136b
lines 1–24why, one step back1import {execPath, execArgv} from 'node:process';2import {basename} from 'node:path';3import {safeNormalizeFileUrl} from './cwd.js';45export const handleNodeOption = (file, args, {6 node: shouldHandleNode = false,7 nodePath = execPath,8 nodeOptions = execArgv.filter(arg => !arg.startsWith('--inspect')),9 ...options10}) => {11 if (!shouldHandleNode) {12 return [file, args, options];13 }1415 if (basename(file, '.exe') === 'node') {16 throw new TypeError('When the "node" option is true, the first argument does not need to be "node".');17 }1819 return [20 safeNormalizeFileUrl(nodePath, 'The "nodePath" option'),21 [...nodeOptions, file, ...args],22 {ipc: true, ...options, shell: false},23 ];24};