command.js
This file
Path
lib/arguments/command.js
22 lines · 966 bytes · JavaScript
Last changed by
Fix `escapedCommand` and `verbose` quoting arguments when using the `shell` optionSindre Sorhusbefore adoptionb2c3a54
History of this fileTake it
1234567891011121314151617181920212223import {logCommand} from '../verbose/start.js';import {getVerboseInfo} from '../verbose/info.js';import {getStartTime} from '../return/duration.js';import {joinCommand} from './escape.js';import {normalizeFdSpecificOption} from './specific.js';
// Compute `result.command`, `result.escapedCommand` and `verbose`-related informationexport const handleCommand = (filePath, rawArguments, rawOptions) => { const startTime = getStartTime(); // The `node` option ignores `shell` const {command, escapedCommand} = joinCommand(filePath, rawArguments, rawOptions.shell && !rawOptions.node); const verbose = normalizeFdSpecificOption(rawOptions, 'verbose'); // Keep the null prototype, otherwise a polluted `Object.prototype` would inject option values const verboseInfo = getVerboseInfo(verbose, escapedCommand, {__proto__: null, ...rawOptions}); logCommand(escapedCommand, verboseInfo); return { command, escapedCommand, startTime, verboseInfo, };};