https://github.com/simplyhexagonal/exec
A convenient async wrapper for Node.js's child_process.exec function
https://github.com/simplyhexagonal/exec
Last synced: about 1 year ago
JSON representation
A convenient async wrapper for Node.js's child_process.exec function
- Host: GitHub
- URL: https://github.com/simplyhexagonal/exec
- Owner: simplyhexagonal
- Created: 2021-11-09T19:11:51.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-16T06:24:34.000Z (about 4 years ago)
- Last Synced: 2025-05-06T20:32:39.951Z (about 1 year ago)
- Language: TypeScript
- Size: 94.7 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Exec

A convenient async wrapper for Node.js's `child_process.exec` function.
```ts
import exec from '@simplyhexagonal/exec';
const {
execProcess,
execPromise,
} = exec('echo hello world');
const successResult = await execPromise;
// successResult {
// "exitCode": 0,
// "stdoutOutput": "hello world\n",
// "stderrOutput": ""
// }
```
```ts
import exec from '@simplyhexagonal/exec';
const {
execProcess,
execPromise,
} = exec(
'>&2 echo hello world && exit 1'
).catch((e) => e);
const failResult = await execPromise;
// failResult {
// "exitCode": 1,
// "stdoutOutput": "",
// "stderrOutput": "hello world\n"
// }
```
```ts
import exec from '@simplyhexagonal/exec';
const {
execProcess,
execPromise,
} = exec('sleep 2; echo hello world');
execProcess.kill('SIGINT');
const killResult = await execPromise;
// killResult {
// "exitCode": null,
// "stdoutOutput": "",
// "stderrOutput": ""
// }
```
## Open source notice
This project is open to updates by its users, [I](https://github.com/jeanlescure) ensure that PRs are relevant to the community.
In other words, if you find a bug or want a new feature, please help us by becoming one of the
[contributors](#contributors-) ✌️ ! See the [contributing section](#contributing)
## Like this module? ❤
Please consider:
- [Buying me a coffee](https://www.buymeacoffee.com/jeanlescure) ☕
- Supporting Simply Hexagonal on [Open Collective](https://opencollective.com/simplyhexagonal) 🏆
- Starring this repo on [Github](https://github.com/simplyhexagonal/exec) 🌟
## Contributing
Yes, thank you! This plugin is community-driven, most of its features are from different authors.
Please update the docs and tests and add your name to the `exec.json` file.
## Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
## License
Copyright (c) 2021-Present [Exec Contributors](https://github.com/simplyhexagonal/exec/#contributors-).
Licensed under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0).