Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKat Marchán <kzm@sykosomatic.org>2018-02-08 20:07:58 +0300
committerRebecca Turner <me@re-becca.org>2018-02-20 05:32:06 +0300
commitdc3059522758470adc225f0651be72c274bd29ef (patch)
treece7c532e7e4d68608ba69a778cceb3d2411d1bda /node_modules/tar
parent94227e15eeced836b3d7b3d2b5e5cc41d4959cff (diff)
tar@4.3.3
Diffstat (limited to 'node_modules/tar')
-rw-r--r--node_modules/tar/README.md29
-rw-r--r--node_modules/tar/lib/header.js4
-rw-r--r--node_modules/tar/lib/mkdir.js1
-rw-r--r--node_modules/tar/lib/parse.js10
-rw-r--r--node_modules/tar/lib/unpack.js87
-rw-r--r--node_modules/tar/node_modules/minizlib/index.js32
-rw-r--r--node_modules/tar/node_modules/minizlib/package.json24
-rw-r--r--node_modules/tar/package.json12
8 files changed, 144 insertions, 55 deletions
diff --git a/node_modules/tar/README.md b/node_modules/tar/README.md
index 62916d713..69b66f179 100644
--- a/node_modules/tar/README.md
+++ b/node_modules/tar/README.md
@@ -316,6 +316,14 @@ The following options are supported:
`uid` option.
- `noMtime` Set to true to omit writing `mtime` value for extracted
entries. [Alias: `m`, `no-mtime`]
+- `transform` Provide a function that takes an `entry` object, and
+ returns a stream, or any falsey value. If a stream is provided,
+ then that stream's data will be written instead of the contents of
+ the archive entry. If a falsey value is provided, then the entry is
+ written to disk as normal. (To exclude items from extraction, use
+ the `filter` option described above.)
+- `onentry` A function that gets called with `(entry)` for each entry
+ that passes the filter.
The following options are mostly internal, but can be modified in some
advanced use cases, such as re-using caches between runs.
@@ -329,6 +337,11 @@ advanced use cases, such as re-using caches between runs.
- `maxMetaEntrySize` The maximum size of meta entries that is
supported. Defaults to 1 MB.
+Note that using an asynchronous stream type with the `transform`
+option will cause undefined behavior in sync extractions.
+[MiniPass](http://npm.im/minipass)-based streams are designed for this
+use case.
+
### tar.t(options, fileList, callback) [alias: tar.list]
List the contents of a tarball archive.
@@ -604,11 +617,27 @@ Most unpack errors will cause a `warn` event to be emitted. If the
`uid` option.
- `noMtime` Set to true to omit writing `mtime` value for extracted
entries.
+- `transform` Provide a function that takes an `entry` object, and
+ returns a stream, or any falsey value. If a stream is provided,
+ then that stream's data will be written instead of the contents of
+ the archive entry. If a falsey value is provided, then the entry is
+ written to disk as normal. (To exclude items from extraction, use
+ the `filter` option described above.)
+- `strict` Treat warnings as crash-worthy errors. Default false.
+- `onentry` A function that gets called with `(entry)` for each entry
+ that passes the filter.
+- `onwarn` A function that will get called with `(message, data)` for
+ any warnings encountered.
### class tar.Unpack.Sync
Synchronous version of `tar.Unpack`.
+Note that using an asynchronous stream type with the `transform`
+option will cause undefined behavior in sync unpack streams.
+[MiniPass](http://npm.im/minipass)-based streams are designed for this
+use case.
+
### class tar.Parse
A writable stream that parses a tar archive stream. All the standard
diff --git a/node_modules/tar/lib/header.js b/node_modules/tar/lib/header.js
index db002e8c1..4de35fa8d 100644
--- a/node_modules/tar/lib/header.js
+++ b/node_modules/tar/lib/header.js
@@ -33,9 +33,9 @@ class Header {
this.atime = null
this.ctime = null
- if (Buffer.isBuffer(data)) {
+ if (Buffer.isBuffer(data))
this.decode(data, off || 0)
- } else if (data)
+ else if (data)
this.set(data)
}
diff --git a/node_modules/tar/lib/mkdir.js b/node_modules/tar/lib/mkdir.js
index 2a8f461af..382329ef5 100644
--- a/node_modules/tar/lib/mkdir.js
+++ b/node_modules/tar/lib/mkdir.js
@@ -145,7 +145,6 @@ const mkdirSync = module.exports.sync = (dir, opt) => {
chownr.sync(created, uid, gid)
if (needChmod)
fs.chmodSync(dir, mode)
- cache.set(dir, true)
}
if (cache && cache.get(dir) === true)
diff --git a/node_modules/tar/lib/parse.js b/node_modules/tar/lib/parse.js
index 01231a61b..090b2d2c0 100644
--- a/node_modules/tar/lib/parse.js
+++ b/node_modules/tar/lib/parse.js
@@ -262,7 +262,8 @@ module.exports = warner(class Parser extends EE {
abort (msg, error) {
this[ABORTED] = true
this.warn(msg, error)
- this.emit('abort')
+ this.emit('abort', error)
+ this.emit('error', error)
}
write (chunk) {
@@ -289,12 +290,15 @@ module.exports = warner(class Parser extends EE {
this[UNZIP] = new zlib.Unzip()
this[UNZIP].on('data', chunk => this[CONSUMECHUNK](chunk))
this[UNZIP].on('error', er =>
- this.abort('zlib error: ' + er.message, er))
+ this.abort(er.message, er))
this[UNZIP].on('end', _ => {
this[ENDED] = true
this[CONSUMECHUNK]()
})
- return ended ? this[UNZIP].end(chunk) : this[UNZIP].write(chunk)
+ this[WRITING] = true
+ const ret = this[UNZIP][ended ? 'end' : 'write' ](chunk)
+ this[WRITING] = false
+ return ret
}
}
diff --git a/node_modules/tar/lib/unpack.js b/node_modules/tar/lib/unpack.js
index fcc765313..3e1c527b6 100644
--- a/node_modules/tar/lib/unpack.js
+++ b/node_modules/tar/lib/unpack.js
@@ -51,6 +51,8 @@ class Unpack extends Parser {
super(opt)
+ this.transform = typeof opt.transform === 'function' ? opt.transform : null
+
this.writable = true
this.readable = false
@@ -86,6 +88,10 @@ class Unpack extends Parser {
this.processGid = (this.preserveOwner || this.setOwner) && process.getgid ?
process.getgid() : null
+ // mostly just for testing, but useful in some cases.
+ // Forcibly trigger a chown on every entry, no matter what
+ this.forceChown = opt.forceChown === true
+
// turn ><?| in filenames into 0xf000-higher encoded forms
this.win32 = !!opt.win32 || process.platform === 'win32'
@@ -222,7 +228,8 @@ class Unpack extends Parser {
[DOCHOWN] (entry) {
// in preserve owner mode, chown if the entry doesn't match process
// in set owner mode, chown if setting doesn't match process
- return this.preserveOwner &&
+ return this.forceChown ||
+ this.preserveOwner &&
( typeof entry.uid === 'number' && entry.uid !== this.processUid ||
typeof entry.gid === 'number' && entry.gid !== this.processGid )
||
@@ -248,30 +255,45 @@ class Unpack extends Parser {
let actions = 1
const done = er => {
- if (er) {
- this[ONERROR](er, entry)
- actions = 1
- }
+ if (er)
+ return this[ONERROR](er, entry)
if (--actions === 0)
fs.close(stream.fd, _ => this[UNPEND]())
}
stream.on('finish', _ => {
+ // if futimes fails, try utimes
+ // if utimes fails, fail with the original error
+ // same for fchown/chown
+ const abs = entry.absolute
+ const fd = stream.fd
+
if (entry.mtime && !this.noMtime) {
actions++
- fs.futimes(stream.fd, entry.atime || new Date(), entry.mtime, done)
+ const atime = entry.atime || new Date()
+ const mtime = entry.mtime
+ fs.futimes(fd, atime, mtime, er =>
+ er ? fs.utimes(abs, atime, mtime, er2 => done(er2 && er))
+ : done())
}
if (this[DOCHOWN](entry)) {
actions++
- fs.fchown(stream.fd, this[UID](entry), this[GID](entry), done)
+ const uid = this[UID](entry)
+ const gid = this[GID](entry)
+ fs.fchown(fd, uid, gid, er =>
+ er ? fs.chown(abs, uid, gid, er2 => done(er2 && er))
+ : done())
}
done()
})
- entry.pipe(stream)
+ const tx = this.transform ? this.transform(entry) || entry : entry
+ if (tx !== entry)
+ entry.pipe(tx)
+ tx.pipe(stream)
}
[DIRECTORY] (entry) {
@@ -427,7 +449,8 @@ class UnpackSync extends Unpack {
const oner = er => {
try { fs.closeSync(fd) } catch (_) {}
- this[ONERROR](er, entry)
+ if (er)
+ this[ONERROR](er, entry)
}
let stream
@@ -437,8 +460,11 @@ class UnpackSync extends Unpack {
} catch (er) {
return oner(er)
}
+ const tx = this.transform ? this.transform(entry) || entry : entry
+ if (tx !== entry)
+ entry.pipe(tx)
- entry.on('data', chunk => {
+ tx.on('data', chunk => {
try {
fs.writeSync(fd, chunk, 0, chunk.length)
} catch (er) {
@@ -446,20 +472,41 @@ class UnpackSync extends Unpack {
}
})
- entry.on('end', _ => {
- try {
- if (entry.mtime && !this.noMtime)
- fs.futimesSync(fd, entry.atime || new Date(), entry.mtime)
+ tx.on('end', _ => {
+ let er = null
+ // try both, falling futimes back to utimes
+ // if either fails, handle the first error
+ if (entry.mtime && !this.noMtime) {
+ const atime = entry.atime || new Date()
+ const mtime = entry.mtime
+ try {
+ fs.futimesSync(fd, atime, mtime)
+ } catch (futimeser) {
+ try {
+ fs.utimesSync(entry.absolute, atime, mtime)
+ } catch (utimeser) {
+ er = futimeser
+ }
+ }
+ }
- if (this[DOCHOWN](entry))
- fs.fchownSync(fd, this[UID](entry), this[GID](entry))
+ if (this[DOCHOWN](entry)) {
+ const uid = this[UID](entry)
+ const gid = this[GID](entry)
- fs.closeSync(fd)
- } catch (er) {
- return oner(er)
+ try {
+ fs.fchownSync(fd, uid, gid)
+ } catch (fchowner) {
+ try {
+ fs.chownSync(entry.absolute, uid, gid)
+ } catch (chowner) {
+ er = er || fchowner
+ }
+ }
}
- })
+ oner(er)
+ })
}
[DIRECTORY] (entry) {
diff --git a/node_modules/tar/node_modules/minizlib/index.js b/node_modules/tar/node_modules/minizlib/index.js
index 8c0df2ac4..10c8a8b48 100644
--- a/node_modules/tar/node_modules/minizlib/index.js
+++ b/node_modules/tar/node_modules/minizlib/index.js
@@ -7,6 +7,18 @@ const binding = process.binding('zlib')
const constants = exports.constants = require('./constants.js')
const MiniPass = require('minipass')
+class ZlibError extends Error {
+ constructor (msg, errno) {
+ super('zlib: ' + msg)
+ this.errno = errno
+ this.code = codes.get(errno)
+ }
+
+ get name () {
+ return 'ZlibError'
+ }
+}
+
// translation table for return codes.
const codes = new Map([
[constants.Z_OK, 'Z_OK'],
@@ -61,10 +73,10 @@ class Zlib extends MiniPass {
this[_opts] = opts = opts || {}
this[_chunkSize] = opts.chunkSize || constants.Z_DEFAULT_CHUNK
if (opts.flush && !validFlushFlags.has(opts.flush)) {
- throw new Error('Invalid flush flag: ' + opts.flush)
+ throw new TypeError('Invalid flush flag: ' + opts.flush)
}
if (opts.finishFlush && !validFlushFlags.has(opts.finishFlush)) {
- throw new Error('Invalid flush flag: ' + opts.finishFlush)
+ throw new TypeError('Invalid flush flag: ' + opts.finishFlush)
}
this[_flushFlag] = opts.flush || constants.Z_NO_FLUSH
@@ -73,37 +85,37 @@ class Zlib extends MiniPass {
if (opts.chunkSize) {
if (opts.chunkSize < constants.Z_MIN_CHUNK) {
- throw new Error('Invalid chunk size: ' + opts.chunkSize)
+ throw new RangeError('Invalid chunk size: ' + opts.chunkSize)
}
}
if (opts.windowBits) {
if (opts.windowBits < constants.Z_MIN_WINDOWBITS ||
opts.windowBits > constants.Z_MAX_WINDOWBITS) {
- throw new Error('Invalid windowBits: ' + opts.windowBits)
+ throw new RangeError('Invalid windowBits: ' + opts.windowBits)
}
}
if (opts.level) {
if (opts.level < constants.Z_MIN_LEVEL ||
opts.level > constants.Z_MAX_LEVEL) {
- throw new Error('Invalid compression level: ' + opts.level)
+ throw new RangeError('Invalid compression level: ' + opts.level)
}
}
if (opts.memLevel) {
if (opts.memLevel < constants.Z_MIN_MEMLEVEL ||
opts.memLevel > constants.Z_MAX_MEMLEVEL) {
- throw new Error('Invalid memLevel: ' + opts.memLevel)
+ throw new RangeError('Invalid memLevel: ' + opts.memLevel)
}
}
if (opts.strategy && !(strategies.has(opts.strategy)))
- throw new Error('Invalid strategy: ' + opts.strategy)
+ throw new TypeError('Invalid strategy: ' + opts.strategy)
if (opts.dictionary) {
if (!(opts.dictionary instanceof Buffer)) {
- throw new Error('Invalid dictionary: it should be a Buffer instance')
+ throw new TypeError('Invalid dictionary: it should be a Buffer instance')
}
}
@@ -116,9 +128,7 @@ class Zlib extends MiniPass {
this.close()
this[_hadError] = true
- const error = new Error(message)
- error.errno = errno
- error.code = codes.get(errno)
+ const error = new ZlibError(message, errno)
this.emit('error', error)
}
diff --git a/node_modules/tar/node_modules/minizlib/package.json b/node_modules/tar/node_modules/minizlib/package.json
index 0a41e31c8..24f915798 100644
--- a/node_modules/tar/node_modules/minizlib/package.json
+++ b/node_modules/tar/node_modules/minizlib/package.json
@@ -1,27 +1,27 @@
{
- "_from": "minizlib@1.0.4",
- "_id": "minizlib@1.0.4",
+ "_from": "minizlib@^1.1.0",
+ "_id": "minizlib@1.1.0",
"_inBundle": false,
- "_integrity": "sha512-sN4U9tIJtBRwKbwgFh9qJfrPIQ/GGTRr1MGqkgOeMTLy8/lM0FcWU//FqlnZ3Vb7gJ+Mxh3FOg1EklibdajbaQ==",
+ "_integrity": "sha512-4T6Ur/GctZ27nHfpt9THOdRZNgyJ9FZchYO1ceg5S8Q3DNLCKYy44nCZzgCJgcvx2UM8czmqak5BCxJMrq37lA==",
"_location": "/tar/minizlib",
"_phantomChildren": {},
"_requested": {
- "type": "version",
+ "type": "range",
"registry": true,
- "raw": "minizlib@1.0.4",
+ "raw": "minizlib@^1.1.0",
"name": "minizlib",
"escapedName": "minizlib",
- "rawSpec": "1.0.4",
+ "rawSpec": "^1.1.0",
"saveSpec": null,
- "fetchSpec": "1.0.4"
+ "fetchSpec": "^1.1.0"
},
"_requiredBy": [
"/tar"
],
- "_resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.0.4.tgz",
- "_shasum": "8ebb51dd8bbe40b0126b5633dbb36b284a2f523c",
- "_spec": "minizlib@1.0.4",
- "_where": "/Users/rebecca/code/npm",
+ "_resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.1.0.tgz",
+ "_shasum": "11e13658ce46bc3a70a267aac58359d1e0c29ceb",
+ "_spec": "minizlib@^1.1.0",
+ "_where": "/Users/zkat/Documents/code/npm/node_modules/tar",
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
@@ -67,5 +67,5 @@
"preversion": "npm test",
"test": "tap test/*.js --100 -J"
},
- "version": "1.0.4"
+ "version": "1.1.0"
}
diff --git a/node_modules/tar/package.json b/node_modules/tar/package.json
index 380b92713..a242c23fa 100644
--- a/node_modules/tar/package.json
+++ b/node_modules/tar/package.json
@@ -1,8 +1,8 @@
{
"_from": "tar@latest",
- "_id": "tar@4.1.1",
+ "_id": "tar@4.3.3",
"_inBundle": false,
- "_integrity": "sha512-p2lLtRABOEhuC28GDpMYwxcDYRqAFfiz2AIZiQlI+fhrACPKtQ1mcF/bPY8T1h9aKlpDpd+WE33Y2PJ/hWhm8g==",
+ "_integrity": "sha512-v9wjbOXloOIeXifMQGkKhPH3H7tjd+8BubFKOTU+64JpFZ3q2zBfsGlnc7KmyRgl8UxVa1SCRiF3F9tqSOgcaQ==",
"_location": "/tar",
"_phantomChildren": {},
"_requested": {
@@ -20,8 +20,8 @@
"/",
"/pacote"
],
- "_resolved": "https://registry.npmjs.org/tar/-/tar-4.1.1.tgz",
- "_shasum": "82fab90e34ac7575f925084de66cc0d2b4a4e040",
+ "_resolved": "https://registry.npmjs.org/tar/-/tar-4.3.3.tgz",
+ "_shasum": "e03823dbde4e8060f606fef7d09f92ce06c1064b",
"_spec": "tar@latest",
"_where": "/Users/zkat/Documents/code/npm",
"author": {
@@ -37,7 +37,7 @@
"chownr": "^1.0.1",
"fs-minipass": "^1.2.3",
"minipass": "^2.2.1",
- "minizlib": "^1.0.4",
+ "minizlib": "^1.1.0",
"mkdirp": "^0.5.0",
"yallist": "^3.0.2"
},
@@ -75,5 +75,5 @@
"preversion": "npm test",
"test": "tap test/*.js --100 -J --coverage-report=text -c"
},
- "version": "4.1.1"
+ "version": "4.3.3"
}