options.js
This file
Path
lib/arguments/options.js
95 lines · 2.7 KiB · JavaScript
Last changed by
Allow template strings with all methods (#933)ehmickybefore adoption8074d85
History of this fileTake it
Split files (#837)ehmickybefore adoption672c2d7
lines 1–6why, one step back1import {basename} from 'node:path';2import process from 'node:process';3import crossSpawn from 'cross-spawn';4import {npmRunPathEnv} from 'npm-run-path';5import {normalizeForceKillAfterDelay} from '../exit/kill.js';6import {validateTimeout} from '../exit/timeout.js';Improve `verbose` option (#883)ehmickybefore adoption7d0943f
line 7why, one step back7import {logCommand} from '../verbose/start.js';Print output with `verbose` option (#884)ehmickybefore adoption6fda30f
line 8why, one step back8import {getVerboseInfo} from '../verbose/info.js';Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
line 9why, one step back9import {getStartTime} from '../return/duration.js';Simplify `lines` option (#929)ehmickybefore adoptiond30fcbc
line 10why, one step back10import {validateEncoding, BINARY_ENCODINGS} from './encoding.js';Split files (#837)ehmickybefore adoption672c2d7
lines 11–12why, one step back11import {handleNodeOption} from './node.js';12import {joinCommand} from './escape.js';Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 13why, one step back13import {normalizeCwd, normalizeFileUrl} from './cwd.js';Split files (#837)ehmickybefore adoption672c2d7
line 14why, one step back14Improve `verbose` option (#883)ehmickybefore adoption7d0943f
line 15why, one step back15export const handleCommand = (filePath, rawArgs, rawOptions) => {Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
line 16why, one step back16 const startTime = getStartTime();Split files (#837)ehmickybefore adoption672c2d7
line 17why, one step back17 const {command, escapedCommand} = joinCommand(filePath, rawArgs);Print output with `verbose` option (#884)ehmickybefore adoption6fda30f
lines 18–19why, one step back18 const verboseInfo = getVerboseInfo(rawOptions);19 logCommand(escapedCommand, verboseInfo, rawOptions);Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
line 20why, one step back20 return {command, escapedCommand, startTime, verboseInfo};Improve `verbose` option (#883)ehmickybefore adoption7d0943f
line 21why, one step back21};Split files (#837)ehmickybefore adoption672c2d7
line 22why, one step back22Allow template strings with all methods (#933)ehmickybefore adoption8074d85
line 23why, one step back23export const handleOptions = (filePath, rawArgs, rawOptions) => {Split files (#837)ehmickybefore adoption672c2d7
lines 24–30why, one step back24 rawOptions.cwd = normalizeCwd(rawOptions.cwd);25 const [processedFile, processedArgs, processedOptions] = handleNodeOption(filePath, rawArgs, rawOptions);2627 const {command: file, args, options: initialOptions} = crossSpawn._parse(processedFile, processedArgs, processedOptions);2829 const options = addDefaultOptions(initialOptions);30 validateTimeout(options);Stricter values for the `encoding` option (#928)ehmickybefore adoption477bbc4
line 31why, one step back31 validateEncoding(options);Split files (#837)ehmickybefore adoption672c2d7
lines 32–34why, one step back32 options.shell = normalizeFileUrl(options.shell);33 options.env = getEnv(options);34 options.forceKillAfterDelay = normalizeForceKillAfterDelay(options.forceKillAfterDelay);Simplify `lines` option (#929)ehmickybefore adoptiond30fcbc
line 35why, one step back35 options.lines &&= !BINARY_ENCODINGS.has(options.encoding) && options.buffer;Split files (#837)ehmickybefore adoption672c2d7
lines 36–41why, one step back3637 if (process.platform === 'win32' && basename(file, '.exe') === 'cmd') {38 // #11639 args.unshift('/q');40 }41Improve `verbose` option (#883)ehmickybefore adoption7d0943f
line 42why, one step back42 return {file, args, options};Split files (#837)ehmickybefore adoption672c2d7
lines 43–61why, one step back43};4445const addDefaultOptions = ({46 maxBuffer = DEFAULT_MAX_BUFFER,47 buffer = true,48 stripFinalNewline = true,49 extendEnv = true,50 preferLocal = false,51 cwd,52 localDir = cwd,53 encoding = 'utf8',54 reject = true,55 cleanup = true,56 all = false,57 windowsHide = true,58 killSignal = 'SIGTERM',59 forceKillAfterDelay = true,60 lines = false,61 ipc = false,Change default value of `serialization` option to `advanced` (#905)ehmickybefore adoption4577582
line 62why, one step back62 serialization = 'advanced',Split files (#837)ehmickybefore adoption672c2d7
lines 63–81why, one step back63 ...options64}) => ({65 ...options,66 maxBuffer,67 buffer,68 stripFinalNewline,69 extendEnv,70 preferLocal,71 cwd,72 localDir,73 encoding,74 reject,75 cleanup,76 all,77 windowsHide,78 killSignal,79 forceKillAfterDelay,80 lines,81 ipc,Change default value of `serialization` option to `advanced` (#905)ehmickybefore adoption4577582
line 82why, one step back82 serialization,Split files (#837)ehmickybefore adoption672c2d7
lines 83–86why, one step back83});8485const DEFAULT_MAX_BUFFER = 1000 * 1000 * 100;86Improve interaction of the `preferLocal`, `node` and `nodePath` options (#841)ehmickybefore adoptionb965682
line 87why, one step back87const getEnv = ({env: envOption, extendEnv, preferLocal, node, localDir, nodePath}) => {Split files (#837)ehmickybefore adoption672c2d7
lines 88–89why, one step back88 const env = extendEnv ? {...process.env, ...envOption} : envOption;89Improve interaction of the `preferLocal`, `node` and `nodePath` options (#841)ehmickybefore adoptionb965682
lines 90–91why, one step back90 if (preferLocal || node) {91 return npmRunPathEnv({env, cwd: localDir, execPath: nodePath, preferLocal, addExecPath: node});Split files (#837)ehmickybefore adoption672c2d7
lines 92–95why, one step back92 }9394 return env;95};