simplyhexagonal / exec

A convenient async wrapper for Node.js's child_process.exec function

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exec

Tests

A convenient async wrapper for Node.js's child_process.exec function.

import exec from '@simplyhexagonal/exec';

const {
  execProcess,
  execPromise,
} = exec('echo hello world');

const successResult = await execPromise;

// successResult {
//   "exitCode": 0,
//   "stdoutOutput": "hello world\n",
//   "stderrOutput": ""
// }
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"
// }
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 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 ✌️ ! See the contributing section

Like this module? ❤

Please consider:

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):


Jean Lescure

🚧 💻 📓 ⚠️ 💡 📖

License

Copyright (c) 2021-Present Exec Contributors.
Licensed under the Apache License 2.0.

About

A convenient async wrapper for Node.js's child_process.exec function


Languages

Language:TypeScript 81.6%Language:Shell 10.0%Language:Handlebars 6.6%Language:JavaScript 1.8%