const subprocess = require("subprocess");
var p = subprocess.call({
command: 'echo',
// Print stdin and our env variable
arguments: ['$@', '$ENV_TEST'],
environment: ['ENV_TEST=OK'],
stdin: subprocess.WritablePipe(function() {
this.write("stdin");
this.close();
}),
stdout: subprocess.ReadablePipe(function(data) {
// data should be equal to: "stdin OK"
}),
stderr: subprocess.ReadablePipe(function(data) {
}),
onFinished: subprocess.Terminate(function() {
}),
mergeStderr: false
});
Patrick Brunschwig (author of almost all code) ,
Ramalingam Saravanan (from enigmail team)