https://github.com/dvonlehman/node-yexec
Yet another process execution wrapper that does what I need it to
https://github.com/dvonlehman/node-yexec
node process spawn
Last synced: about 2 months ago
JSON representation
Yet another process execution wrapper that does what I need it to
- Host: GitHub
- URL: https://github.com/dvonlehman/node-yexec
- Owner: dvonlehman
- Created: 2016-04-26T15:46:33.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2019-01-19T17:15:09.000Z (about 7 years ago)
- Last Synced: 2025-08-30T21:19:46.213Z (7 months ago)
- Topics: node, process, spawn
- Language: JavaScript
- Size: 22.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# yexec
[](https://travis-ci.org/dvonlehman/node-yexec)
[](https://coveralls.io/github/dvonlehman/node-yexec?branch=master)
Yet another process execution wrapper. Uses `child_process.spawn` to execute an external process and capture `stdout` and `stderr`.
- Logs `stdout` and `stderr` to a logger implementation of your choice as long as it supports the standard level functions like `info`, `warn`, and `error`.
- Supports optional log filter
- Protects against double callbacks from `error` and `exit` events.
- Throws an Error if process exits with non-zero code
- Specify an optional timeout. If the process has not exited within the interval the process is force killed and a `TIMEOUT` error is thrown.
### Usage
```sh
npm install yexec
```
```js
var yexec = require('yexec');
var winston = require('winston');
var params = {
executable: 'git',
args: ['clone', 'https://github.com/nodejs/node.git'],
logger: winston,
timeout: 5000, // 5 seconds
logFilter: function(level, msg) {
return level !== 'info';
}
};
try {
await yexec(params);
} catch (err) {
// If timeout occurred, err.code will be 'TIMEOUT'
winston.error('Oops, git failed with code %s', err.code);
}
```