diff options
Diffstat (limited to 'deps/npm/node_modules/pacote/lib/fetchers/git.js')
-rw-r--r-- | deps/npm/node_modules/pacote/lib/fetchers/git.js | 8 |
1 files changed, 5 insertions, 3 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) |