1.3.3 • Published 6 years ago

@player1os/spawn-process-async v1.3.3

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

NodeJS Spawn Process Async

A promise wrapper of the standard Node.js library for spawning a process.

const { default: spawnProcessAsync } = require('@player1os/spawn-process-async')

const result = await spawnProcessAsync('echo', ['"Hello World!"'])

console.log(result.outStreamData) // outputs: Hello World!

The implementation is designed similarly to childProcess.spawnSync in that it does not allow any interaction with the spawned process until it has exited. The difference is that since this is an asynchronous implementation, the process does not block.

The implementation forces the process to be spawned in a separate shell (which is slower, but simplifies cross-platform usage).

By default the process's output and error streams are buffered and transformed to utf-8 strings, contained in the return value. By setting the optional parameter options.isStdioInherited to true, the child's streams are forwarded to the parent process.

Finally the function throws a ProcessError Error object if the process returns with a non-zero status code. This Error object contains information about the process. This behaviour can be disabled by setting the optional parameter options.isErrorOnNonZeroStatusCodeSuppressed to true.