find-node-modules
Version:
Return an array of all parent node_modules directories
23 lines (20 loc) • 465 B
JavaScript
;
function createErr (code, stderr) {
return new Error(stderr);
}
module.exports = function (child, errFactory) {
errFactory = errFactory || createErr;
var stderr = [];
child.stderr.on('data', function (chunk) {
stderr.push(chunk);
});
child.on('close', function (code) {
if (code !== 0) {
child.stdout.emit('error', errFactory(
code,
Buffer.concat(stderr).toString()
));
}
});
return child;
};