spawn-process
v2.0.0
Published
Promise wrapper for `child_process.spawn`
Downloads
198
Readme
spawn-process
Promise wrapper for child_process.spawn
.
Installation
npm install spawn-process
Usage
spawnProcess
will resolve with the stdout output or reject with the stderr.
import spawnProcess from 'spawn-process';
(async () => {
const stdout = await spawnProcess('echo', ['Hello world']);
console.log(stdout);
})();
With spawn options
You can pass any options from child_process.spawn
, for example piping inputs and outputs:
import spawnProcess from 'spawn-process';
(async () => {
await spawnProcess('echo', ['Hello world'], {
stdio: [process.stdin, process.stdout, process.stderr],
});
})();
With CommonJS / require()
const spawnProcess = require('spawn-process');
spawnProcess('echo', ['Hello world']).then((stdout) => {
console.log(stdout);
});