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.
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
- Windows:
- Fowrards all stdio streams to current terminal (by default):
- try
execSh("bash")
- try
execsh("echo -n Say: && read i && echo Said:$i")
- try
- stdout and stderr are passed to callback when available
- try
execSh("pwd", console.log)
- try
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)