1.2.8 • Published 9 years ago

@exponent/spawn-async v1.2.8

Weekly downloads
29
License
MIT
Repository
github
Last release
9 years ago

spawn-async CircleCI Build Status

A cross-platform version of Node's child_process.spawn as an async function that returns a promise.

Usage:

import spawnAsync from '@exponent/spawn-async';

let resultPromise = spawnAsync('echo', ['hello', 'world'], { stdio: 'inherit' });
let spawnedChildProcess = resultPromise.child;
try {
  let {
    pid,
    output: [stdout, stderr],
    stdout,
    stderr,
    status,
    signal,
  } = await resultPromise;
} catch (e) {
  console.error(e.stack);
  // The error object also has the same properties as the result object
}

API

spawnAsync takes the same arguments as child_process.spawn.

It returns a promise whose result is an object with these properties:

  • pid: the process ID of the spawned child process
  • output: an array with stdout and stderr's output
  • stdout: a string of what the child process wrote to stdout
  • stderr: a string of what the child process wrote to stderr
  • status: the exit code of the child process
  • signal: the signal (ex: SIGTERM) used to stop the child process if it did not exit on its own

If there's an error running the child process or it exits with a non-zero status code, spawnAsync rejects the returned promise. The Error object also has the properties listed above.

1.2.8

9 years ago

1.2.7

9 years ago

1.2.6

9 years ago

1.2.5

9 years ago

1.2.4

10 years ago

1.2.3

10 years ago

1.2.2

10 years ago

1.2.1

10 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago