Skip to content
Myr

command.js

This file

Path

lib/command.js

18 lines · 525 bytes · JavaScript

Last changed by

Split files (#791)ehmickybefore adoption932fb26

History of this file

Take it

The walk stopped after 200 commits: lines older than 09df476 point at it.

Meta tweaksSindre Sorhusbefore adoption09df476

lines 1–7why, one step back
1const SPACES_REGEXP = / +/g;
23// Handle `execaCommand()`4export const parseCommand = command => {5 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 delimiter

Require Node.js 16 (#569)ehmickybefore adoption65992b4

line 8why, one step back
8 const previousToken = tokens.at(-1);

Meta tweaksSindre Sorhusbefore adoption09df476

lines 9–18why, one step back
9 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};