Contains utility functions for executing commands.
| Interface |
Description |
| ExecArgument |
A command argument that contains a list of args to be batched. If the expanded command exceeds the platform’s max command length, the batched args are split into sequential executions. |
| ExecDetailedOptions |
Options for exec that return detailed results. |
| ExecOptions |
Options for executing a command. |
| ExecResult |
A result of exec. |
| ExecSimpleOptions |
Options for exec that return only stdout. |
| Function |
Description |
| appendNodeOption |
Appends a single node CLI option to a NODE_OPTIONS string, preserving any options already present. |
| buildChildEnv |
Builds the environment for child processes: the parent environment plus DEBUG_COLORS, and — when the running node supports it — LOCAL_STORAGE_NODE_OPTION appended to NODE_OPTIONS. The support check guards against older node (< 22): passing an option node does not recognize via NODE_OPTIONS makes it exit before running, which would break every spawned tool. |
| exec |
Executes a command. |
| 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. |
| getMaxBatchCommandLength |
Returns the max command line length to size an ExecArgument batch against — the platform maximum less WINDOWS_CHILD_EXPANSION_RESERVE. Deliberately more conservative than getMaxCommandLength, because the two answer different questions. Exceeding the plain-command limit is a hard failure the caller cannot avoid, so that check stays exact. Exceeding the batching limit only costs one extra invocation, so that check may — and should — leave room to spare. |