mirror of
https://github.com/shimataro/ssh-key-action.git
synced 2025-06-19 22:52:10 +10:00
17 lines
419 B
JavaScript
17 lines
419 B
JavaScript
'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)
|
|
}
|
|
})
|
|
})
|
|
}
|