pacote
Advanced tools
Comparing version 2.1.1 to 2.1.2
@@ -5,2 +5,7 @@ # Change Log | ||
<a name="2.1.2"></a> | ||
## [2.1.2](https://github.com/zkat/pacote/compare/v2.1.1...v2.1.2) (2017-04-20) | ||
<a name="2.1.1"></a> | ||
@@ -7,0 +12,0 @@ ## [2.1.1](https://github.com/zkat/pacote/compare/v2.1.0...v2.1.1) (2017-04-19) |
@@ -26,12 +26,12 @@ 'use strict' | ||
return extractByManifest(startTime, spec, dest, opts) | ||
} else if (err.code === 'EINTEGRITY') { | ||
opts.log.warn('pacote', `cached data for ${opts.integrity} failed integrity check. Refreshing cache.`) | ||
return cleanUpCached( | ||
dest, opts.cache, opts.integrity, opts | ||
).then(() => { | ||
return extractByManifest(startTime, spec, dest, opts) | ||
}) | ||
} else { | ||
throw err | ||
} | ||
if (err.code === 'EINTEGRITY' || err.code === 'Z_DATA_ERROR') { | ||
opts.log.warn('pacote', `cached data for ${spec} (${opts.integrity}) seems to be corrupted. Refreshing cache.`) | ||
} | ||
return cleanUpCached( | ||
dest, opts.cache, opts.integrity, opts | ||
).then(() => { | ||
return extractByManifest(startTime, spec, dest, opts) | ||
}) | ||
}) | ||
@@ -44,6 +44,9 @@ } else { | ||
).catch(err => { | ||
// We're only going to retry at this level if the local cache might | ||
// have gotten corrupted. | ||
if (err.code === 'EINTEGRITY' && opts.cache) { | ||
opts.log.warn('pacote', `tarball integrity check for ${spec.name}@${spec.saveSpec || spec.fetchSpec} failed. Clearing cache entry. ${err.message}`) | ||
// Retry once if we have a cache, to clear up any weird conditions. | ||
// Don't retry network errors, though -- make-fetch-happen has already | ||
// taken care of making sure we're all set on that front. | ||
if (opts.cache && !err.code.match(/^E\d{3}$/)) { | ||
if (err.code === 'EINTEGRITY' || err.code === 'Z_DATA_ERROR') { | ||
opts.log.warn('pacote', `tarball data for ${spec} (${opts.integrity}) seems to be corrupted. Trying one more time.`) | ||
} | ||
return cleanUpCached( | ||
@@ -50,0 +53,0 @@ dest, opts.cache, err.sri, opts |
'use strict' | ||
var cacache = require('cacache') | ||
var cacheKey = require('./cache-key') | ||
const cacache = require('cacache') | ||
const cacheKey = require('./cache-key') | ||
module.exports = cacache | ||
module.exports.key = cacheKey |
'use strict' | ||
var gunzip = require('./util/gunzip-maybe') | ||
var path = require('path') | ||
var pipeline = require('mississippi').pipeline | ||
var tar = require('tar-fs') | ||
const gunzip = require('./util/gunzip-maybe') | ||
const path = require('path') | ||
const pipeline = require('mississippi').pipeline | ||
const tar = require('tar-fs') | ||
@@ -11,5 +11,5 @@ module.exports = extractStream | ||
opts = opts || {} | ||
var sawIgnores = {} | ||
const sawIgnores = {} | ||
return pipeline(gunzip(), tar.extract(dest, { | ||
map: function (header) { | ||
map: (header) => { | ||
if (process.platform !== 'win32') { | ||
@@ -24,7 +24,7 @@ header.uid = opts.uid == null ? header.uid : opts.uid | ||
if (header.type === 'file') { | ||
var base = path.basename(header.name) | ||
const base = path.basename(header.name) | ||
if (base === '.npmignore') { | ||
sawIgnores[header.name] = true | ||
} else if (base === '.gitignore') { | ||
var npmignore = header.name.replace(/\.gitignore$/, '.npmignore') | ||
const npmignore = header.name.replace(/\.gitignore$/, '.npmignore') | ||
if (!sawIgnores[npmignore]) { | ||
@@ -47,6 +47,4 @@ // Rename, may be clobbered later. | ||
function makeIgnore (log) { | ||
var sawIgnores = {} | ||
return function (name, header) { | ||
return _ignore(name, header, sawIgnores, log) | ||
} | ||
const sawIgnores = {} | ||
return (name, header) => _ignore(name, header, sawIgnores, log) | ||
} | ||
@@ -53,0 +51,0 @@ |
'use strict' | ||
var BB = require('bluebird') | ||
const BB = require('bluebird') | ||
var semver = require('semver') | ||
const semver = require('semver') | ||
module.exports = pickManifest | ||
function pickManifest (metadata, spec, opts) { | ||
var distTags = metadata['dist-tags'] || {} | ||
var versions = Object.keys(metadata.versions || {}) | ||
versions = versions.filter(function (v) { return semver.valid(v) }) | ||
var err | ||
const distTags = metadata['dist-tags'] || {} | ||
const versions = Object.keys(metadata.versions || {}).filter(v => semver.valid(v)) | ||
let err | ||
return BB.fromNode(cb => { | ||
@@ -22,3 +21,3 @@ if (!versions.length) { | ||
var target | ||
let target | ||
@@ -33,3 +32,3 @@ if (spec.type === 'tag') { | ||
var tagVersion = distTags[opts.defaultTag || 'latest'] | ||
const tagVersion = distTags[opts.defaultTag || 'latest'] | ||
@@ -59,3 +58,3 @@ if ( | ||
var manifest = target && metadata.versions[target] | ||
const manifest = target && metadata.versions[target] | ||
if (!manifest) { | ||
@@ -62,0 +61,0 @@ err = new Error(`No matching version found for ${spec.name}@${spec.fetchSpec}`) |
'use strict' | ||
var url = require('url') | ||
const url = require('url') | ||
@@ -9,4 +9,4 @@ // Called a nerf dart in the main codebase. Used as a "safe" | ||
function registryKey (registry) { | ||
var parsed = url.parse(registry) | ||
var formatted = url.format({ | ||
const parsed = url.parse(registry) | ||
const formatted = url.format({ | ||
host: parsed.host, | ||
@@ -13,0 +13,0 @@ path: parsed.path, |
'use strict' | ||
var duplex = require('mississippi').duplex | ||
var through = require('mississippi').through | ||
var zlib = require('zlib') | ||
const duplex = require('mississippi').duplex | ||
const through = require('mississippi').through | ||
const zlib = require('zlib') | ||
@@ -13,5 +13,5 @@ function hasGzipHeader (c) { | ||
function gunzip () { | ||
var stream = duplex() | ||
var peeker = through(function (chunk, enc, cb) { | ||
var newStream = hasGzipHeader(chunk) | ||
const stream = duplex() | ||
const peeker = through((chunk, enc, cb) => { | ||
const newStream = hasGzipHeader(chunk) | ||
? zlib.createGunzip() | ||
@@ -18,0 +18,0 @@ : through() |
'use strict' | ||
var noop = Function.prototype | ||
const noop = Function.prototype | ||
module.exports = { | ||
@@ -5,0 +5,0 @@ error: noop, |
{ | ||
"name": "pacote", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "JavaScript package downloader", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
66478
1455