JSPM

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

Call a child process with the ease of exec and safety of spawn

Package Exports

  • 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 (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

Call a child process with the ease of exec and safety of spawn

Why?

This module provides the best of both worlds of spawn and exec

It will simply return 2 strings containing stdout and stderr (like child_process.exec), but will take an array of process arguments (like child_process.spawn) to avoid any nasty shell expansion.

Usage

var exec = require('exec');

Example

var exec = require('exec');

exec(['ls', '-lha'], function(err, out, code) {
  if (err) throw err;
  console.log(out);
  process.exit(code);
});

The example above will call ls -lha safely, by passing the arguments directly to exec(2) without using an shell expansion/ word splitting.

It returns a child_process.spawn object, and callbacks with any stdout, stderr, and the exit status of the command. The above example will throw an error if any errors were produced, otherwise it will just print the output (with a trailing newline) and exit with the exit code of ls.

License

MIT