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
12345678910111213141516171819202122232425import {execPath, execArgv} from 'node:process';import {basename} from 'node:path';import {safeNormalizeFileUrl} from './cwd.js';
export const handleNodeOption = (file, args, { node: shouldHandleNode = false, nodePath = execPath, nodeOptions = execArgv.filter(arg => !arg.startsWith('--inspect')), ...options}) => { if (!shouldHandleNode) { return [file, args, options]; }
if (basename(file, '.exe') === 'node') { throw new TypeError('When the "node" option is true, the first argument does not need to be "node".'); }
return [ safeNormalizeFileUrl(nodePath, 'The "nodePath" option'), [...nodeOptions, file, ...args], {ipc: true, ...options, shell: false}, ];};