node.js - Promise.promisify get parameters from position 2..n in then resolution -
the first time posted confused actual issue was. in bluebird documentation promisify, says
the node function should conform node.js convention of accepting callback last argument , calling callback error first argument , success value on second argument.
this means parameter in 1st position (error) passed .catch
. parameter in 2nd position passed .then
. if there more 1 "success" value, how capture parameters 3rd position , on? child_process.exec
callback function called function (error, stdout, stderr)
. there anyway capture stderr
in promisify
'd function? this
var promise = require('bluebird'); var child_process = promise.promisifyall(require('child_process')); var execasync = child_process.execasync; var exec = child_process.exec; // normal callback, can access stderr exec('node-gyp rebuild', function(error, stdout, stderr) { console.log(stderr); }); execasync('node-gyp rebuild') .then(function(stdout, stderr) { console.log(stderr); // > undefined }) .catch(function(error) { // });
Comments
Post a Comment