command.js
This file
Path
lib/command.js
25 lines · 866 bytes · JavaScript
Last changed by
Allow template strings with all methods (#933)ehmickybefore adoption8074d85
History of this fileTake it
The walk stopped after 200 commits: lines older than 640ae39 point at it.
Allow template strings with all methods (#933)ehmickybefore adoption8074d85
lines 1–2why, one step back1export const mapCommandAsync = ({file, args}) => parseCommand(file, args);2export const mapCommandSync = ({file, args}) => ({...parseCommand(file, args), isSync: true});Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 3why, one step back3Allow template strings with all methods (#933)ehmickybefore adoption8074d85
lines 4–6why, one step back4const parseCommand = (command, unusedArgs) => {5 if (unusedArgs.length > 0) {6 throw new TypeError(`The command and its arguments must be passed as a single string: ${command} ${unusedArgs}.`);Improve error message when passing wrong arguments to `execaCommand()` (#899)ehmickybefore adoptiond1889f6
lines 7–8why, one step back7 }8Fix `stdio` option (#634)ehmickybefore adoption640ae39
lines 9–20why, one step back9 const tokens = [];10 for (const token of command.trim().split(SPACES_REGEXP)) {11 // Allow spaces to be escaped by a backslash if not meant as a delimiter12 const previousToken = tokens.at(-1);13 if (previousToken && previousToken.endsWith('\\')) {14 // Merge previous token with current one15 tokens[tokens.length - 1] = `${previousToken.slice(0, -1)} ${token}`;16 } else {17 tokens.push(token);18 }19 }20Allow template strings with all methods (#933)ehmickybefore adoption8074d85
lines 21–22why, one step back21 const [file, ...args] = tokens;22 return {file, args};Fix `stdio` option (#634)ehmickybefore adoption640ae39
line 23why, one step back23};Split files (#837)ehmickybefore adoption672c2d7
lines 24–25why, one step back2425const SPACES_REGEXP = / +/g;