Skip to content
Myr

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 file

Take it

Add `node` option (#804)ehmickybefore adoption663136b

line 1why, one step back
1import {execPath, execArgv} from 'node:process';

Merge `execPath` and `nodePath` options (#812)ehmickybefore adoptionfa04e3c

line 2why, one step back
2import {basename, resolve} from 'node:path';

Add `node` option (#804)ehmickybefore adoption663136b

lines 3–8why, one step back
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')),

Merge `execPath` and `nodePath` options (#812)ehmickybefore adoptionfa04e3c

lines 9–10why, one step back
9 cwd,
10 execPath: formerNodePath,

Add `node` option (#804)ehmickybefore adoption663136b

lines 11–12why, one step back
11 ...options
12}) => {

Merge `execPath` and `nodePath` options (#812)ehmickybefore adoptionfa04e3c

lines 13–20why, one step back
13 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};20

Add `node` option (#804)ehmickybefore adoption663136b

line 21why, one step back
21 if (!shouldHandleNode) {

Merge `execPath` and `nodePath` options (#812)ehmickybefore adoptionfa04e3c

line 22why, one step back
22 return [file, args, newOptions];

Add `node` option (#804)ehmickybefore adoption663136b

lines 23–29why, one step back
23 }
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 back
30 resolvedNodePath,

Add `node` option (#804)ehmickybefore adoption663136b

line 31why, one step back
31 [...nodeOptions, file, ...args],

Merge `execPath` and `nodePath` options (#812)ehmickybefore adoptionfa04e3c

line 32why, one step back
32 {ipc: true, ...newOptions, shell: false},

Add `node` option (#804)ehmickybefore adoption663136b

lines 33–34why, one step back
33 ];
34};