Add documentation about nano-spawn (#1157)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by ehmicky · committed by GitHub · parent 3fc8049 · Browse files · 4 files·+48 added−2 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+48 added−2 removed
- other:+48 added−2 removed
Provenance
- Commit
eb3cfba- Tree
54cb309- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
3fc8049
4 files changed+48 added−2 removed
modified:docs/bash.md+1 added-1 removed
1267 unmodified lines1268 [More info.](https://github.com/sindresorhus/p-retry)1269 1270 <hr>1271 1272-[**Next**: 🤓 TypeScript](typescript.md)\1272+[**Next**: 🐭 Small packages](small.md)\1273 [**Previous**: 📎 Windows](windows.md)\1274 [**Top**: Table of contents](../readme.md#documentation)added:docs/small.md+44 added
1234567891011121314151617181920212223242526272829303132333435363738394041424344<picture> <source media="(prefers-color-scheme: dark)" srcset="../media/logo_dark.svg"> <img alt="execa logo" src="../media/logo.svg" width="400"></picture><br>
# 🐭 Small packages
## `nano-spawn`
Execa aims to be the best way to run commands on Node.js. It is [very widely used](https://github.com/sindresorhus/execa/network/dependents), [battle-tested](https://github.com/sindresorhus/execa/graphs/contributors) and has a bunch of [features](../readme.md#features).
However, this means it has a relatively big package size: [](https://packagephobia.com/result?p=execa). This should not be a problem in a server-side context, such as a script, a server, or an app. But you might be in an environment requiring small packages, such as a library or a serverless function.
If so, you can use [nano-spawn](https://github.com/sindresorhus/nano-spawn). It is similar, is maintained by the [same people](https://github.com/sindresorhus/nano-spawn#maintainers), has no dependencies, and a smaller package size:  [](https://packagephobia.com/result?p=nano-spawn).
On the other hand, please note `nano-spawn` lacks many features from Execa: [scripts](scripts.md), [template string syntax](execution.md#template-string-syntax), [synchronous execution](execution.md#synchronous-execution), [file input/output](output.md#file-output), [binary input/output](binary.md), [advanced piping](pipe.md), [verbose mode](debugging.md#verbose-mode), [graceful](termination.md#graceful-termination) or [forceful termination](termination.md#forceful-termination), [IPC](ipc.md), [shebangs on Windows](windows.md), [and much more](https://github.com/sindresorhus/nano-spawn/issues/14).
```jsimport spawn from 'nano-spawn';
const result = await spawn('npm', ['run', 'build']);```
### `node:child_process`
Both Execa and nano-spawn are built on top of the [`node:child_process`](https://nodejs.org/api/child_process.html) core module.
If you'd prefer avoiding adding any dependency, you may use `node:child_process` directly. However, you might miss some basic [features](https://github.com/sindresorhus/nano-spawn#features) that both Execa and nano-spawn provide: [proper error handling](https://github.com/sindresorhus/nano-spawn#subprocesserror), [full Windows support](https://github.com/sindresorhus/nano-spawn#windows-support), [local binaries](https://github.com/sindresorhus/nano-spawn#optionspreferlocal), [piping](https://github.com/sindresorhus/nano-spawn#subprocesspipefile-arguments-options), [lines iteration](https://github.com/sindresorhus/nano-spawn#subprocesssymbolasynciterator), [interleaved output](https://github.com/sindresorhus/nano-spawn#resultoutput), [and more](https://github.com/sindresorhus/nano-spawn#features).
```jsimport {execFile} from 'node:child_process';import {promisify} from 'node:util';
const pExecFile = promisify(execFile);
const result = await pExecFile('npm', ['run', 'build']);```
<hr>
[**Next**: 🤓 TypeScript](typescript.md)\[**Previous**: 🔍 Differences with Bash and zx](bash.md)\[**Top**: Table of contents](../readme.md#documentation)modified:docs/typescript.md+1 added-1 removed
185 unmodified lines186 187 <hr>188 189 [**Next**: 📔 API reference](api.md)\190-[**Previous**: 🔍 Differences with Bash and zx](bash.md)\190+[**Previous**: 🐭 Small packages](small.md)\191 [**Top**: Table of contents](../readme.md#documentation)modified:readme.md+2 added
101 unmodified lines102 - 📞 [Inter-process communication](docs/ipc.md)103 - 🐛 [Debugging](docs/debugging.md)104 - 📎 [Windows](docs/windows.md)105 - 🔍 [Difference with Bash and zx](docs/bash.md)106+- 🐭 [Small packages](docs/small.md)107 - 🤓 [TypeScript](docs/typescript.md)108 - 📔 [API reference](docs/api.md)109 110 ## Examples329 unmodified lines440 ```441 442 ## Related443 444+- [nano-spawn](https://github.com/sindresorhus/nano-spawn) - Like Execa but [smaller](docs/small.md)445 - [gulp-execa](https://github.com/ehmicky/gulp-execa) - Gulp plugin for Execa446 - [nvexeca](https://github.com/ehmicky/nvexeca) - Run Execa using any Node.js version447 448 ## Maintainers3 unmodified lines