lspeasy / core/src / tokenizeCommand
Function: tokenizeCommand()
function tokenizeCommand(command): string[];Defined in: packages/core/src/utils/tokenize-command.ts:15
Split a server launch command into argv tokens, honoring single- and double-quoted spans so an argument containing spaces survives intact (e.g. node "/path with spaces/server.js" --stdio). A naive split(/\s+/) shredded such commands into broken fragments.
This is a deliberately small, dependency-free tokenizer (matching the repo's "no extra dependency" ethos): quotes group and unquoted whitespace separates tokens. Crucially, a backslash is a LITERAL path separator (so Windows paths like "C:\Program Files\server.exe" survive intact) — it escapes ONLY a following quote character (\" inside a double-quoted span yields a literal "). It is not a full POSIX shell parser (no variable/glob expansion) — only the quoting needed to pass paths/args.
Parameters
| Parameter | Type |
|---|---|
command | string |
Returns
string[]