diff options
Diffstat (limited to 'deps/npm/node_modules/pacote/lib/util/finished.js')
-rw-r--r-- | deps/npm/node_modules/pacote/lib/util/finished.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/deps/npm/node_modules/pacote/lib/util/finished.js b/deps/npm/node_modules/pacote/lib/util/finished.js new file mode 100644 index 0000000000..6dadc8b5b3 --- /dev/null +++ b/deps/npm/node_modules/pacote/lib/util/finished.js @@ -0,0 +1,17 @@ +'use strict' + +const BB = require('bluebird') + +module.exports = function (child, hasExitCode = false) { + return BB.fromNode(function (cb) { + child.on('error', cb) + child.on(hasExitCode ? 'close' : 'end', function (exitCode) { + if (exitCode === undefined || exitCode === 0) { + cb() + } else { + let err = new Error('exited with error code: ' + exitCode) + cb(err) + } + }) + }) +} |