tar 4.4.4 → 4.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/lib/header.js +19 -3
- package/lib/parse.js +2 -1
- package/lib/unpack.js +12 -2
- package/lib/write-entry.js +12 -2
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -108,7 +108,7 @@ tar.c( // or tar.create
|
|
|
108
108
|
gzip: <true|gzip options>
|
|
109
109
|
},
|
|
110
110
|
['some', 'files', 'and', 'folders']
|
|
111
|
-
).pipe(fs.createWriteStream('my-tarball.tgz')
|
|
111
|
+
).pipe(fs.createWriteStream('my-tarball.tgz'))
|
|
112
112
|
```
|
|
113
113
|
|
|
114
114
|
To replicate `tar xf my-tarball.tgz` you'd do:
|
|
@@ -230,6 +230,9 @@ The following options are supported:
|
|
|
230
230
|
Note that this prevents using other mtime-based features like
|
|
231
231
|
`tar.update` or the `keepNewer` option with the resulting tar archive.
|
|
232
232
|
[Alias: `m`, `no-mtime`]
|
|
233
|
+
- `mtime` Set to a `Date` object to force a specific `mtime` for
|
|
234
|
+
everything added to the archive. Overridden by `noMtime`.
|
|
235
|
+
|
|
233
236
|
|
|
234
237
|
The following options are mostly internal, but can be modified in some
|
|
235
238
|
advanced use cases, such as re-using caches between runs.
|
package/lib/header.js
CHANGED
|
@@ -9,10 +9,11 @@ const types = require('./types.js')
|
|
|
9
9
|
const pathModule = require('path').posix
|
|
10
10
|
const large = require('./large-numbers.js')
|
|
11
11
|
|
|
12
|
+
const SLURP = Symbol('slurp')
|
|
12
13
|
const TYPE = Symbol('type')
|
|
13
14
|
|
|
14
15
|
class Header {
|
|
15
|
-
constructor (data, off) {
|
|
16
|
+
constructor (data, off, ex, gex) {
|
|
16
17
|
this.cksumValid = false
|
|
17
18
|
this.needPax = false
|
|
18
19
|
this.nullBlock = false
|
|
@@ -35,12 +36,12 @@ class Header {
|
|
|
35
36
|
this.ctime = null
|
|
36
37
|
|
|
37
38
|
if (Buffer.isBuffer(data))
|
|
38
|
-
this.decode(data, off || 0)
|
|
39
|
+
this.decode(data, off || 0, ex, gex)
|
|
39
40
|
else if (data)
|
|
40
41
|
this.set(data)
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
decode (buf, off) {
|
|
44
|
+
decode (buf, off, ex, gex) {
|
|
44
45
|
if (!off)
|
|
45
46
|
off = 0
|
|
46
47
|
|
|
@@ -55,6 +56,11 @@ class Header {
|
|
|
55
56
|
this.mtime = decDate(buf, off + 136, 12)
|
|
56
57
|
this.cksum = decNumber(buf, off + 148, 12)
|
|
57
58
|
|
|
59
|
+
// if we have extended or global extended headers, apply them now
|
|
60
|
+
// See https://github.com/npm/node-tar/pull/187
|
|
61
|
+
this[SLURP](ex)
|
|
62
|
+
this[SLURP](gex, true)
|
|
63
|
+
|
|
58
64
|
// old tar versions marked dirs as a file with a trailing /
|
|
59
65
|
this[TYPE] = decString(buf, off + 156, 1)
|
|
60
66
|
if (this[TYPE] === '')
|
|
@@ -101,6 +107,16 @@ class Header {
|
|
|
101
107
|
this.nullBlock = true
|
|
102
108
|
}
|
|
103
109
|
|
|
110
|
+
[SLURP] (ex, global) {
|
|
111
|
+
for (let k in ex) {
|
|
112
|
+
// we slurp in everything except for the path attribute in
|
|
113
|
+
// a global extended header, because that's weird.
|
|
114
|
+
if (ex[k] !== null && ex[k] !== undefined &&
|
|
115
|
+
!(global && k === 'path'))
|
|
116
|
+
this[k] = ex[k]
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
104
120
|
encode (buf, off) {
|
|
105
121
|
if (!buf) {
|
|
106
122
|
buf = this.block = Buffer.alloc(512)
|
package/lib/parse.js
CHANGED
|
@@ -29,6 +29,7 @@ const maxMetaEntrySize = 1024 * 1024
|
|
|
29
29
|
const Entry = require('./read-entry.js')
|
|
30
30
|
const Pax = require('./pax.js')
|
|
31
31
|
const zlib = require('minizlib')
|
|
32
|
+
const Buffer = require('./buffer.js')
|
|
32
33
|
|
|
33
34
|
const gzipHeader = Buffer.from([0x1f, 0x8b])
|
|
34
35
|
const STATE = Symbol('state')
|
|
@@ -101,7 +102,7 @@ module.exports = warner(class Parser extends EE {
|
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
[CONSUMEHEADER] (chunk, position) {
|
|
104
|
-
const header = new Header(chunk, position)
|
|
105
|
+
const header = new Header(chunk, position, this[EX], this[GEX])
|
|
105
106
|
|
|
106
107
|
if (header.nullBlock)
|
|
107
108
|
this[EMIT]('nullBlock')
|
package/lib/unpack.js
CHANGED
|
@@ -178,6 +178,12 @@ class Unpack extends Parser {
|
|
|
178
178
|
if (parts.length < this.strip)
|
|
179
179
|
return false
|
|
180
180
|
entry.path = parts.slice(this.strip).join('/')
|
|
181
|
+
|
|
182
|
+
if (entry.type === 'Link') {
|
|
183
|
+
const linkparts = entry.linkpath.split(/\/|\\/)
|
|
184
|
+
if (linkparts.length >= this.strip)
|
|
185
|
+
entry.linkpath = linkparts.slice(this.strip).join('/')
|
|
186
|
+
}
|
|
181
187
|
}
|
|
182
188
|
|
|
183
189
|
if (!this.preservePaths) {
|
|
@@ -331,8 +337,10 @@ class Unpack extends Parser {
|
|
|
331
337
|
})
|
|
332
338
|
|
|
333
339
|
const tx = this.transform ? this.transform(entry) || entry : entry
|
|
334
|
-
if (tx !== entry)
|
|
340
|
+
if (tx !== entry) {
|
|
341
|
+
tx.on('error', er => this[ONERROR](er, entry))
|
|
335
342
|
entry.pipe(tx)
|
|
343
|
+
}
|
|
336
344
|
tx.pipe(stream)
|
|
337
345
|
}
|
|
338
346
|
|
|
@@ -512,8 +520,10 @@ class UnpackSync extends Unpack {
|
|
|
512
520
|
return oner(er)
|
|
513
521
|
}
|
|
514
522
|
const tx = this.transform ? this.transform(entry) || entry : entry
|
|
515
|
-
if (tx !== entry)
|
|
523
|
+
if (tx !== entry) {
|
|
524
|
+
tx.on('error', er => this[ONERROR](er, entry))
|
|
516
525
|
entry.pipe(tx)
|
|
526
|
+
}
|
|
517
527
|
|
|
518
528
|
tx.on('data', chunk => {
|
|
519
529
|
try {
|
package/lib/write-entry.js
CHANGED
|
@@ -227,11 +227,21 @@ const WriteEntry = warner(class WriteEntry extends MiniPass {
|
|
|
227
227
|
|
|
228
228
|
[ONREAD] (fd, buf, offset, length, pos, remain, blockRemain, bytesRead) {
|
|
229
229
|
if (bytesRead <= 0 && remain > 0) {
|
|
230
|
-
const er = new Error('unexpected EOF')
|
|
230
|
+
const er = new Error('encountered unexpected EOF')
|
|
231
231
|
er.path = this.absolute
|
|
232
232
|
er.syscall = 'read'
|
|
233
233
|
er.code = 'EOF'
|
|
234
|
-
this
|
|
234
|
+
this[CLOSE](fd)
|
|
235
|
+
return this.emit('error', er)
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (bytesRead > remain) {
|
|
239
|
+
const er = new Error('did not encounter expected EOF')
|
|
240
|
+
er.path = this.absolute
|
|
241
|
+
er.syscall = 'read'
|
|
242
|
+
er.code = 'EOF'
|
|
243
|
+
this[CLOSE](fd)
|
|
244
|
+
return this.emit('error', er)
|
|
235
245
|
}
|
|
236
246
|
|
|
237
247
|
// null out the rest of the buffer, if we could fit the block padding
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
|
|
3
3
|
"name": "tar",
|
|
4
4
|
"description": "tar for node",
|
|
5
|
-
"version": "4.4.
|
|
5
|
+
"version": "4.4.8",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/npm/node-tar.git"
|
|
@@ -16,23 +16,23 @@
|
|
|
16
16
|
"bench": "for i in benchmarks/*/*.js; do echo $i; for j in {1..5}; do node $i || break; done; done"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"chownr": "^1.
|
|
19
|
+
"chownr": "^1.1.1",
|
|
20
20
|
"fs-minipass": "^1.2.5",
|
|
21
|
-
"minipass": "^2.3.
|
|
22
|
-
"minizlib": "^1.1.
|
|
21
|
+
"minipass": "^2.3.4",
|
|
22
|
+
"minizlib": "^1.1.1",
|
|
23
23
|
"mkdirp": "^0.5.0",
|
|
24
24
|
"safe-buffer": "^5.1.2",
|
|
25
25
|
"yallist": "^3.0.2"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"chmodr": "^1.0
|
|
28
|
+
"chmodr": "^1.2.0",
|
|
29
29
|
"end-of-stream": "^1.4.1",
|
|
30
30
|
"events-to-array": "^1.1.2",
|
|
31
31
|
"mutate-fs": "^2.1.1",
|
|
32
32
|
"rimraf": "^2.6.2",
|
|
33
33
|
"tap": "^12.0.1",
|
|
34
|
-
"tar-fs": "^1.16.
|
|
35
|
-
"tar-stream": "^1.6.
|
|
34
|
+
"tar-fs": "^1.16.3",
|
|
35
|
+
"tar-stream": "^1.6.2"
|
|
36
36
|
},
|
|
37
37
|
"license": "ISC",
|
|
38
38
|
"engines": {
|