Skip to content
Myr

node.js

This file

Path

lib/methods/node.js

47 lines · 1.3 KiB · JavaScript

Last changed by

Upgrade xo (#980)ehmickybefore adoptionccfa412

History of this file

Take it

Rename files (#977)ehmickybefore adoption4b2e316

lines 1–12why, one step back
1import {execPath, execArgv} from 'node:process';
2import {basename, resolve} from 'node:path';3import {safeNormalizeFileUrl} from '../arguments/file-url.js';45export const mapNode = ({options}) => {6 if (options.node === false) {7 throw new TypeError('The "node" option cannot be false with `execaNode()`.');8 }910 return {options: {...options, node: true}};11};12

Upgrade xo (#980)ehmickybefore adoptionccfa412

line 13why, one step back
13export const handleNodeOption = (file, commandArguments, {

Rename files (#977)ehmickybefore adoption4b2e316

lines 14–15why, one step back
14 node: shouldHandleNode = false,
15 nodePath = execPath,

Upgrade xo (#980)ehmickybefore adoptionccfa412

line 16why, one step back
16 nodeOptions = execArgv.filter(nodeOption => !nodeOption.startsWith('--inspect')),

Rename files (#977)ehmickybefore adoption4b2e316

lines 17–26why, one step back
17 cwd,
18 execPath: formerNodePath,19 ...options20}) => {21 if (formerNodePath !== undefined) {22 throw new TypeError('The "execPath" option has been removed. Please use the "nodePath" option instead.');23 }2425 const normalizedNodePath = safeNormalizeFileUrl(nodePath, 'The "nodePath" option');26 const resolvedNodePath = resolve(cwd, normalizedNodePath);

Upgrade xo (#980)ehmickybefore adoptionccfa412

lines 27–32why, one step back
27 const newOptions = {
28 ...options,29 nodePath: resolvedNodePath,30 node: shouldHandleNode,31 cwd,32 };

Rename files (#977)ehmickybefore adoption4b2e316

lines 33–34why, one step back
33
34 if (!shouldHandleNode) {

Upgrade xo (#980)ehmickybefore adoptionccfa412

line 35why, one step back
35 return [file, commandArguments, newOptions];

Rename files (#977)ehmickybefore adoption4b2e316

lines 36–43why, one step back
36 }
3738 if (basename(file, '.exe') === 'node') {39 throw new TypeError('When the "node" option is true, the first argument does not need to be "node".');40 }4142 return [43 resolvedNodePath,

Upgrade xo (#980)ehmickybefore adoptionccfa412

line 44why, one step back
44 [...nodeOptions, file, ...commandArguments],

Rename files (#977)ehmickybefore adoption4b2e316

lines 45–47why, one step back
45 {ipc: true, ...newOptions, shell: false},
46 ];47};