command.js
This file
Path
lib/command.js
18 lines · 525 bytes · JavaScript
Last changed by
Split files (#791)ehmickybefore adoption932fb26
History of this fileTake it
The walk stopped after 200 commits: lines older than fd3c7be point at it.
Add `.escapedCommand` property (#466)ehmickybefore adoption712bafc
lines 1–2why, one step back1const SPACES_REGEXP = / +/g;2Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
lines 3–4why, one step back3// Handle `execaCommand()`4export const parseCommand = command => {Rename `master` branch to `main`Sindre Sorhusbefore adoptionfd3c7be
lines 5–7why, one step back5 const tokens = [];6 for (const token of command.trim().split(SPACES_REGEXP)) {7 // Allow spaces to be escaped by a backslash if not meant as a delimiterRequire Node.js 16 (#569)ehmickybefore adoption65992b4
line 8why, one step back8 const previousToken = tokens.at(-1);Rename `master` branch to `main`Sindre Sorhusbefore adoptionfd3c7be
lines 9–18why, one step back9 if (previousToken && previousToken.endsWith('\\')) {10 // Merge previous token with current one11 tokens[tokens.length - 1] = `${previousToken.slice(0, -1)} ${token}`;12 } else {13 tokens.push(token);14 }15 }1617 return tokens;18};