Improve documentation for `windowsVerbatimArguments` (#1149)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by ehmicky · committed by GitHub · parent 0a51f7c · Browse files · 2 files·+26 added−4 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+26 added−4 removed
- other:+26 added−4 removed
Provenance
- Commit
c4cb62a- Tree
501d374- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
0a51f7c
2 files changed+26 added−4 removed
modified:docs/api.md+1 added-1 removed
1168 unmodified lines1169 _Default:_ `true` if the [`shell`](#optionsshell) option is `true`, `false` otherwise1170 1171 If `false`, escapes the command arguments on Windows.1172 1173-[More info.](windows.md#cmdexe-escaping)1173+[More info.](windows.md#escaping)1174 1175 ## Verbose function1176 1177 _Type_: `(string, VerboseObject) => string | undefined`130 unmodified linesmodified:docs/windows.md+25 added-3 removed
32 unmodified lines33343536373738393940414142434445464748495051525354555657585960616263646566676811 unmodified lines32 unmodified linesThe default value for the [`stdin`](api.md#optionsstdin), [`stdout`](api.md#optionsstdout) and [`stderr`](api.md#optionsstderr) options is [`'pipe'`](output.md#stdout-and-stderr). This returns the output as [`result.stdout`](api.md#resultstdout) and [`result.stderr`](api.md#resultstderr) and allows for [manual streaming](streams.md#manual-streaming).
Instead of `'pipe'`, `'overlapped'` can be used instead to use [asynchronous I/O](https://learn.microsoft.com/en-us/windows/win32/fileio/synchronous-and-asynchronous-i-o) under-the-hood on Windows, instead of the default behavior which is synchronous. On other platforms, asynchronous I/O is always used, so `'overlapped'` behaves the same way as `'pipe'`.
## `cmd.exe` escaping## Escaping
If the [`windowsVerbatimArguments`](api.md#optionswindowsverbatimarguments) option is `false`, the [command arguments](input.md#command-arguments) are automatically escaped on Windows. When using a [`cmd.exe`](https://en.wikipedia.org/wiki/Cmd.exe) [shell](api.md#optionsshell), this is `true` by default instead.Windows requires files and arguments to be quoted when they contain spaces, tabs, backslashes or double quotes. Unlike Unix, this is needed even when no [shell](shell.md) is used.
This is ignored on other platforms: those are [automatically escaped](escaping.md) by default.When not using any shell, Execa performs that quoting automatically. This ensures files and arguments are split correctly.
```jsawait execa`npm run ${'task with space'}`;```
When using a [shell](shell.md), the user must manually perform shell-specific quoting, on both Unix and Windows. When the [`shell`](api.md#optionsshell) option is `true`, [`cmd.exe`](https://en.wikipedia.org/wiki/Cmd.exe) is used on Windows and `sh` on Unix. Unfortunately, both shells use different quoting rules. With `cmd.exe`, this mostly involves double quoting arguments and prepending double quotes with a backslash.
```jsif (isWindows) { await execa({shell: true})`npm run ${'"task with space"'}`;} else { await execa({shell: true})`npm run ${'\'task with space\''}`;}```
When using other Windows shells (such as PowerShell or WSL), Execa performs `cmd.exe`-specific automatic quoting by default. This is a problem since Powershell uses different quoting rules. This can be disabled using the [`windowsVerbatimArguments: true`](api.md#optionswindowsverbatimarguments) option.
```jsif (isWindows) { await execa({windowsVerbatimArguments: true})`wsl ...`;}```
## Console window
If the [`windowsHide`](api.md#optionswindowshide) option is `false`, the subprocess is run in a new console window. This is necessary to make [`SIGINT` work](https://github.com/nodejs/node/issues/29837) on Windows, and to prevent subprocesses not being cleaned up in [some specific situations](https://github.com/sindresorhus/execa/issues/433).
11 unmodified lines