diff options
Diffstat (limited to 'deps/npm/node_modules/pacote/lib')
5 files changed, 24 insertions, 11 deletions
diff --git a/deps/npm/node_modules/pacote/lib/fetchers/git.js b/deps/npm/node_modules/pacote/lib/fetchers/git.js index 9da6a6438a..a5f51cd6c0 100644 --- a/deps/npm/node_modules/pacote/lib/fetchers/git.js +++ b/deps/npm/node_modules/pacote/lib/fetchers/git.js @@ -65,7 +65,7 @@ Fetcher.impl(fetchGit, { return withTmp(opts, tmp => { if (streamError) { throw streamError } return cloneRepo( - manifest._repo, manifest._ref, manifest._rawRef, tmp, opts + spec, manifest._repo, manifest._ref, manifest._rawRef, tmp, opts ).then(HEAD => { if (streamError) { throw streamError } manifest._resolved = spec.saveSpec.replace(/(:?#.*)?$/, `#${HEAD}`) @@ -158,8 +158,10 @@ function withTmp (opts, cb) { } } -function cloneRepo (repo, resolvedRef, rawRef, tmp, opts) { - if (resolvedRef) { +// Only certain whitelisted hosted gits support shadow cloning +const SHALLOW_HOSTS = new Set(['github', 'gist', 'gitlab', 'bitbucket']) +function cloneRepo (spec, repo, resolvedRef, rawRef, tmp, opts) { + if (resolvedRef && spec.hosted && SHALLOW_HOSTS.has(spec.hosted.type)) { return git.shallow(repo, resolvedRef.ref, tmp, opts) } else { return git.clone(repo, rawRef, tmp, opts) diff --git a/deps/npm/node_modules/pacote/lib/fetchers/registry/check-warning-header.js b/deps/npm/node_modules/pacote/lib/fetchers/registry/check-warning-header.js index bd4dbc5175..b17a233d43 100644 --- a/deps/npm/node_modules/pacote/lib/fetchers/registry/check-warning-header.js +++ b/deps/npm/node_modules/pacote/lib/fetchers/registry/check-warning-header.js @@ -21,11 +21,14 @@ function checkWarnings (res, registry, opts) { } }) BAD_HOSTS.set(registry, true) - if (warnings['199'] && warnings['199'].message.match(/ENOTFOUND/)) { - opts.log.warn('registry', `Using stale data from ${registry} because the host is inaccessible -- are you offline?`) - } else if (warnings['199']) { - opts.log.warn('registry', `Unexpected warning for ${registry}: ${warnings['199'].message}`) - } else if (warnings['111']) { + if (warnings['199']) { + if (warnings['199'].message.match(/ENOTFOUND/)) { + opts.log.warn('registry', `Using stale data from ${registry} because the host is inaccessible -- are you offline?`) + } else { + opts.log.warn('registry', `Unexpected warning for ${registry}: ${warnings['199'].message}`) + } + } + if (warnings['111']) { // 111 Revalidation failed -- we're using stale data opts.log.warn( 'registry', diff --git a/deps/npm/node_modules/pacote/lib/fetchers/registry/manifest.js b/deps/npm/node_modules/pacote/lib/fetchers/registry/manifest.js index febebfbde5..be67c2e455 100644 --- a/deps/npm/node_modules/pacote/lib/fetchers/registry/manifest.js +++ b/deps/npm/node_modules/pacote/lib/fetchers/registry/manifest.js @@ -88,7 +88,7 @@ function fetchPackument (uri, spec, registry, opts) { // Force integrity to null: we never check integrity hashes for manifests integrity: null })).then(res => res.json().then(packument => { - packument._cached = res.headers.has('x-local-cache') + packument._cached = decodeURIComponent(res.headers.has('x-local-cache')) packument._contentLength = +res.headers.get('content-length') // NOTE - we need to call pickMem again because proxy // objects get reused! diff --git a/deps/npm/node_modules/pacote/lib/fetchers/registry/tarball.js b/deps/npm/node_modules/pacote/lib/fetchers/registry/tarball.js index 8ad2b6860b..2c63872e7f 100644 --- a/deps/npm/node_modules/pacote/lib/fetchers/registry/tarball.js +++ b/deps/npm/node_modules/pacote/lib/fetchers/registry/tarball.js @@ -51,7 +51,10 @@ function fromManifest (manifest, spec, opts) { ], spec }, opts)).then(res => { - stream.emit('integrity', res.headers.get('x-local-cache-hash')) + const hash = res.headers.get('x-local-cache-hash') + if (hash) { + stream.emit('integrity', decodeURIComponent(hash)) + } res.body.on('error', err => stream.emit('error', err)) res.body.pipe(stream) }).catch(err => stream.emit('error', err)) diff --git a/deps/npm/node_modules/pacote/lib/util/git.js b/deps/npm/node_modules/pacote/lib/util/git.js index fc3d158fa7..ed1b49d56a 100644 --- a/deps/npm/node_modules/pacote/lib/util/git.js +++ b/deps/npm/node_modules/pacote/lib/util/git.js @@ -109,8 +109,13 @@ function revs (repo, opts) { env: gitEnv() }, opts).then(child => { let stdout = '' + let stderr = '' child.stdout.on('data', d => { stdout += d }) - return finished(child).then(() => { + child.stderr.on('data', d => { stderr += d }) + return finished(child).catch(err => { + err.message = `Error while executing:\n${GITPATH} ls-remote -h -t ${repo}\n\n${stderr}\n${err.message}` + throw err + }).then(() => { return stdout.split('\n').reduce((revs, line) => { const split = line.split(/\s+/, 2) if (split.length < 2) { return revs } |