Skip to content

Latest commit

 

History

History
57 lines (34 loc) · 3.19 KB

windows.md

File metadata and controls

57 lines (34 loc) · 3.19 KB
execa logo

📎 Windows

Although each OS implements subprocesses very differently, Execa makes them cross-platform, except in a few instances.

Shebang

On Unix, executable files can use shebangs.

import {execa} from 'execa';

// If script.js starts with #!/usr/bin/env node
await execa`./script.js`;

// Then, the above is a shortcut for:
await execa`node ./script.js`;

Although Windows does not natively support shebangs, Execa adds support for them.

Signals

Only few signals work on Windows with Node.js: SIGTERM, SIGKILL, SIGINT and SIGQUIT. Also, sending signals from other processes is not supported. Finally, the forceKillAfterDelay option is a noop on Windows.

Asynchronous I/O

The default value for the stdin, stdout and stderr options is 'pipe'. This returns the output as result.stdout and result.stderr and allows for manual streaming.

Instead of 'pipe', 'overlapped' can be used instead to use 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

If the windowsVerbatimArguments option is false, the command arguments are automatically escaped on Windows. When using a cmd.exe shell, this is true by default instead.

This is ignored on other platforms: those are automatically escaped by default.

Console window

If the windowsHide option is false, the subprocess is run in a new console window. This is necessary to make SIGINT work on Windows, and to prevent subprocesses not being cleaned up in some specific situations.

UID and GID

By default, subprocesses are run using the current user and group. The uid and gid options can be used to set a different user or group.

However, since Windows uses a different permission model, those options throw.


Next: 🔍 Differences with Bash and zx
Previous: 🐛 Debugging
Top: Table of contents