I promisified child_process.execFile, and now cannot figure out how to get at the error output, if the executable fails (returns nonzero). Example code:
var Promise = require("bluebird");
var execFile = Promise.promisify(require("child_process").execFile,
{multiArgs: true});
execFile('/usr/bin/cat', ["heia"]).then(function(args) {
console.log("OK\n");
var stdout = args[0];
var stderr = args[1];
console.log(JSON.stringify(stdout));
console.log(JSON.stringify(stderr));
}).catch(function(err) {
console.log("ERROR\n");
console.log(JSON.stringify(err));
});
This works fine, if the file exists, but if "heia" does not exist, I want to see what "cat" printed (which in this case would be "cat: heia: No such file or directory"). How to do that?
I tried adding extra arguments to "catch(function(err, ...) but they turned out to be undefined.
Erkki