summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/pacote/lib/util/git.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/pacote/lib/util/git.js')
-rw-r--r--deps/npm/node_modules/pacote/lib/util/git.js29
1 files changed, 18 insertions, 11 deletions
diff --git a/deps/npm/node_modules/pacote/lib/util/git.js b/deps/npm/node_modules/pacote/lib/util/git.js
index 9196212278..997404dd23 100644
--- a/deps/npm/node_modules/pacote/lib/util/git.js
+++ b/deps/npm/node_modules/pacote/lib/util/git.js
@@ -74,10 +74,10 @@ function fullClone (repo, committish, target, opts) {
if (process.platform === 'win32') {
gitArgs.push('--config', 'core.longpaths=true')
}
- return execGit(gitArgs, {cwd: target}).then(() => {
- return execGit(['init'], {cwd: target})
+ return execGit(gitArgs, { cwd: target }, opts).then(() => {
+ return execGit(['init'], { cwd: target }, opts)
}).then(() => {
- return execGit(['checkout', committish || 'HEAD'], {cwd: target})
+ return execGit(['checkout', committish || 'HEAD'], { cwd: target }, opts)
}).then(() => {
return updateSubmodules(target, opts)
}).then(() => headSha(target, opts))
@@ -110,7 +110,7 @@ function updateSubmodules (localRepo, opts) {
function headSha (repo, opts) {
opts = optCheck(opts)
- return execGit(['rev-parse', '--revs-only', 'HEAD'], {cwd: repo}, opts).spread(stdout => {
+ return execGit(['rev-parse', '--revs-only', 'HEAD'], { cwd: repo }, opts).spread(stdout => {
return stdout.trim()
})
}
@@ -139,7 +139,7 @@ function revs (repo, opts) {
if (!ref) { return revs } // ???
if (ref.endsWith(CARET_BRACES)) { return revs } // refs/tags/x^{} crap
const type = refType(line)
- const doc = {sha, ref, type}
+ const doc = { sha, ref, type }
revs.refs[ref] = doc
// We can check out shallow clones on specific SHAs if we have a ref
@@ -157,7 +157,7 @@ function revs (repo, opts) {
}
return revs
- }, {versions: {}, 'dist-tags': {}, refs: {}, shas: {}})
+ }, { versions: {}, 'dist-tags': {}, refs: {}, shas: {} })
}, err => {
err.message = `Error while executing:\n${GITPATH} ls-remote -h -t ${repo}\n\n${err.stderr}\n${err.message}`
throw err
@@ -182,7 +182,7 @@ function revs (repo, opts) {
module.exports._exec = execGit
function execGit (gitArgs, gitOpts, opts) {
opts = optCheck(opts)
- return checkGit().then(gitPath => {
+ return checkGit(opts).then(gitPath => {
return promiseRetry((retry, number) => {
if (number !== 1) {
opts.log.silly('pacote', 'Retrying git command: ' + gitArgs.join(' ') + ' attempt # ' + number)
@@ -194,14 +194,19 @@ function execGit (gitArgs, gitOpts, opts) {
throw err
}
})
- }, opts.retry)
+ }, opts.retry != null ? opts.retry : {
+ retries: opts['fetch-retries'],
+ factor: opts['fetch-retry-factor'],
+ maxTimeout: opts['fetch-retry-maxtimeout'],
+ minTimeout: opts['fetch-retry-mintimeout']
+ })
})
}
module.exports._spawn = spawnGit
function spawnGit (gitArgs, gitOpts, opts) {
opts = optCheck(opts)
- return checkGit().then(gitPath => {
+ return checkGit(opts).then(gitPath => {
return promiseRetry((retry, number) => {
if (number !== 1) {
opts.log.silly('pacote', 'Retrying git command: ' + gitArgs.join(' ') + ' attempt # ' + number)
@@ -241,8 +246,10 @@ function mkOpts (_gitOpts, opts) {
return gitOpts
}
-function checkGit () {
- if (!GITPATH) {
+function checkGit (opts) {
+ if (opts.git) {
+ return BB.resolve(opts.git)
+ } else if (!GITPATH) {
const err = new Error('No git binary found in $PATH')
err.code = 'ENOGIT'
return BB.reject(err)