JSPM

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

Execute shell command forwarding all stdio.

Package Exports

  • exec-sh

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-sh) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

exec-sh

Execute shell command forwarding all stdio streams.

Build Status NPM version David Status


Showcase

// JavaScript

execSh("echo hello exec-sh && bash", { cwd: "/home" }, function(err){
  if (err) {
    console.log("Exit code: ", err.code);
  }
});
// Terminal output: interactive bash session

hello exec-sh
bash-3.2$ pwd
/home
bash-3.2$ exit 99
exit
Exit code:  99

Features

exec-sh is a wrapper for child_process.spawn with improvements:

  • Cross platform command execution:
    • Windows: cmd /C COMMAND
    • others: sh -c COMMAND
  • Fowrards all stdio streams to current terminal (by default):
    • try execSh("bash")
    • try execsh("echo -n Say: && read i && echo Said:$i")
  • stdout and stderr are passed to callback when available
    • try execSh("pwd", console.log)

Installation

npm install exec-sh

Usage

var execSh = require("../");

// run interactive bash shell
execSh("echo lorem && bash", { cwd: "/home" }, function(err){
  if (err) {
    console.log("Exit code: ", err.code);
    return;
  }

  // collect streams output
  var child = execSh(["bash -c id", "echo lorem >&2"], true,
    function(err, stdout, stderr){
      console.log("error: ", err);
      console.log("stdout: ", stdout);
      console.log("stderr: ", stderr);
    });
});

Release history

  • 0.1.0 Initial release

Testing

npm test

License

The MIT License (MIT)

Bitdeli Badge