Skip to content
This repository has been archived by the owner on Jul 3, 2019. It is now read-only.

Commit

Permalink
fix(git): workaround for mississippi.finished intermitent failures (#144
Browse files Browse the repository at this point in the history
)

Fixes: #143
  • Loading branch information
andreineculau authored and zkat committed Apr 17, 2018
1 parent 118157c commit 788fd13
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/finalize-manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const BB = require('bluebird')
const cacache = require('cacache')
const cacheKey = require('./util/cache-key')
const fetchFromManifest = require('./fetch').fromManifest
const finished = BB.promisify(require('mississippi').finished)
const finished = require('./util/finished')
const minimatch = require('minimatch')
const normalize = require('normalize-package-data')
const optCheck = require('./util/opt-check')
Expand Down
17 changes: 17 additions & 0 deletions lib/util/finished.js
Original file line number Diff line number Diff line change
@@ -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)
}
})
})
}
4 changes: 2 additions & 2 deletions lib/util/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const cp = require('child_process')
const execFileAsync = BB.promisify(cp.execFile, {
multiArgs: true
})
const finished = BB.promisify(require('mississippi').finished)
const finished = require('./finished')
const LRU = require('lru-cache')
const optCheck = require('./opt-check')
const osenv = require('osenv')
Expand Down Expand Up @@ -213,7 +213,7 @@ function spawnGit (gitArgs, gitOpts, opts) {
child.stdout.on('data', d => { stdout += d })
child.stderr.on('data', d => { stderr += d })

return finished(child).catch(err => {
return finished(child, true).catch(err => {
if (shouldRetry(stderr)) {
retry(err)
} else {
Expand Down

0 comments on commit 788fd13

Please sign in to comment.