summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/pacote/lib/fetchers
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/pacote/lib/fetchers')
-rw-r--r--deps/npm/node_modules/pacote/lib/fetchers/file.js31
-rw-r--r--deps/npm/node_modules/pacote/lib/fetchers/git.js15
-rw-r--r--deps/npm/node_modules/pacote/lib/fetchers/registry/manifest.js3
3 files changed, 39 insertions, 10 deletions
diff --git a/deps/npm/node_modules/pacote/lib/fetchers/file.js b/deps/npm/node_modules/pacote/lib/fetchers/file.js
index 8217f5015b..48bec0c2d8 100644
--- a/deps/npm/node_modules/pacote/lib/fetchers/file.js
+++ b/deps/npm/node_modules/pacote/lib/fetchers/file.js
@@ -2,9 +2,10 @@
const BB = require('bluebird')
+const cacache = require('cacache')
const Fetcher = require('../fetch')
const fs = require('fs')
-const pipe = require('mississippi').pipe
+const pipe = BB.promisify(require('mississippi').pipe)
const through = require('mississippi').through
const readFileAsync = BB.promisify(fs.readFile)
@@ -29,15 +30,39 @@ Fetcher.impl(fetchFile, {
const src = spec._resolved || spec.fetchSpec
const stream = through()
statAsync(src).then(stat => {
+ if (spec._resolved) { stream.emit('manifest', spec) }
if (stat.size <= MAX_BULK_SIZE) {
// YAY LET'S DO THING IN BULK
return readFileAsync(src).then(data => {
- stream.write(data, () => {
+ if (opts.cache) {
+ return cacache.put(
+ opts.cache, `pacote:tarball:file:${src}`, data, {
+ integrity: opts.integrity
+ }
+ ).then(integrity => ({data, integrity}))
+ } else {
+ return {data}
+ }
+ }).then(info => {
+ if (info.integrity) { stream.emit('integrity', info.integrity) }
+ stream.write(info.data, () => {
stream.end()
})
})
} else {
- return pipe(fs.createReadStream(src), stream)
+ let integrity
+ const cacheWriter = !opts.cache
+ ? BB.resolve(null)
+ : (pipe(
+ fs.createReadStream(src),
+ cacache.put.stream(opts.cache, `pacote:tarball:${src}`, {
+ integrity: opts.integrity
+ }).on('integrity', d => { integrity = d })
+ ))
+ return cacheWriter.then(() => {
+ if (integrity) { stream.emit('integrity', integrity) }
+ return pipe(fs.createReadStream(src), stream)
+ })
}
}, err => stream.emit('error', err))
return stream
diff --git a/deps/npm/node_modules/pacote/lib/fetchers/git.js b/deps/npm/node_modules/pacote/lib/fetchers/git.js
index a5f51cd6c0..11b5695255 100644
--- a/deps/npm/node_modules/pacote/lib/fetchers/git.js
+++ b/deps/npm/node_modules/pacote/lib/fetchers/git.js
@@ -111,19 +111,21 @@ function plainManifest (repo, spec, opts) {
_spec: spec,
_ref: ref,
_rawRef: spec.gitCommittish || spec.gitRange,
- _uniqueResolved: resolved
+ _uniqueResolved: resolved,
+ _integrity: false
}
} else {
// We're SOL and need a full clone :(
//
// If we're confident enough that `rawRef` is a commit SHA,
// then we can at least get `finalize-manifest` to cache its result.
- const resolved = spec.saveSpec.replace(/(?:#.*)?$/, `#${rawRef}`)
+ const resolved = spec.saveSpec.replace(/(?:#.*)?$/, rawRef ? `#${rawRef}` : '')
return {
_repo: repo,
_rawRef: rawRef,
- _resolved: rawRef.match(/^[a-f0-9]{40}$/) && resolved,
- _uniqueResolved: rawRef.match(/^[a-f0-9]{40}$/) && resolved
+ _resolved: rawRef && rawRef.match(/^[a-f0-9]{40}$/) && resolved,
+ _uniqueResolved: rawRef && rawRef.match(/^[a-f0-9]{40}$/) && resolved,
+ _integrity: false
}
}
})
@@ -161,9 +163,10 @@ function withTmp (opts, cb) {
// 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) {
+ const ref = resolvedRef ? resolvedRef.ref : rawRef
if (resolvedRef && spec.hosted && SHALLOW_HOSTS.has(spec.hosted.type)) {
- return git.shallow(repo, resolvedRef.ref, tmp, opts)
+ return git.shallow(repo, ref, tmp, opts)
} else {
- return git.clone(repo, rawRef, tmp, opts)
+ return git.clone(repo, ref, tmp, opts)
}
}
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 be67c2e455..4488ddb4c7 100644
--- a/deps/npm/node_modules/pacote/lib/fetchers/registry/manifest.js
+++ b/deps/npm/node_modules/pacote/lib/fetchers/registry/manifest.js
@@ -37,7 +37,8 @@ function getManifest (uri, registry, spec, opts) {
return fetchPackument(uri, spec, registry, opts).then(packument => {
try {
return pickManifest(packument, spec.fetchSpec, {
- defaultTag: opts.defaultTag
+ defaultTag: opts.defaultTag,
+ includeDeprecated: opts.includeDeprecated
})
} catch (err) {
if (err.code === 'ETARGET' && packument._cached && !opts.offline) {