JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 109
  • Score
    100M100P100Q84002F
  • License MIT

Process spawning APIs beautified

Package Exports

  • sb-exec

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sb-exec) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Exec

Greenkeeper badge

Node's Process spawning APIs beautified

Installation

npm install --save sb-exec

API

type $OptionsAccepted = {
  timeout?: number | Infinity, // In milliseconds
  stream?: 'stdout' | 'stderr'  | 'both',
  env: Object,
  stdin?: string | Buffer,
  local?: {
    directory: string,
    prepend?: boolean
  },
  throwOnStderr?: boolean = true,
  allowEmptyStderr?: boolean = false,
  ignoreExitCode?: boolean
} // Also supports all options of child_process::spawn

type PromisedProcess = {
  then(callback: Function): Promise
  catch(callback: Function): Promise
  kill(signal: number)
}

export function exec(filePath: string, parameters: array, options: $OptionsAccepted): PromisedProcess
export function execNode(filePath: string, parameters: array, options: $OptionsAccepted): PromisedProcess

Explanation

Promise callbacks

  • then callback is supposed to accept one of these results, depending on options.stream:
    • stdout and stderr will result in a string, representing an stdout or stderr stream, respectively.
    • both will result in an object of {stdout, stderr, exitCode} representing their respective streams and an exit code of a process.
    • If options.stream is not provided it is assumed to be stdout, so a promise will result in a string representing an stdout stream.

options.local

options.local adds node executables in node_modules relative to options.local.directory to PATH like in npm scripts.

options.local.prepend prioritizes local executables over ones already in PATH.

License

This project is licensed under the terms of MIT License, see the LICENSE file for more info