getEffectiveCommandLineLength
Returns the length of the command line as the operating system will actually see it, which on Windows is NOT the length of the string passed in.
spawnViaShell routes the command through cmd.exe, and two things are spent between here and there, neither of them visible in the assembled command: - Node’s spawn(…, { shell: true }) wraps it as <comspec> /d /s /c "<command>". - cmdEscapeCommandLine ^-escapes every one of cmd.exe’s metacharacters, which on a list of quoted paths is a few percent of the whole (measured: +236 chars on a 7216-char invocation).
Both are ours to compute, so they are computed rather than guessed. What is NOT computable from here is what the spawned command does to its own arguments — see WINDOWS_CHILD_EXPANSION_RESERVE.
The platform branch here MUST stay in sync with the one in spawnViaShell.
Import:
import { getEffectiveCommandLineLength } from '@mnaoumov/typescript-dev-toolkit/exec';Signature:
function getEffectiveCommandLineLength(commandLine: string): numberParameters:
| Parameter | Type | Description |
|---|---|---|
commandLine |
string | The assembled command line, before any shell wrapping. |
Returns: number — The length in characters of what reaches the operating system.