tar 6.1.0 → 6.1.1

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.
@@ -0,0 +1,14 @@
1
+ // unix absolute paths are also absolute on win32, so we use this for both
2
+ const { isAbsolute, parse } = require('path').win32
3
+
4
+ // returns [root, stripped]
5
+ module.exports = path => {
6
+ let r = ''
7
+ while (isAbsolute(path)) {
8
+ // windows will think that //x/y/z has a "root" of //x/y/
9
+ const root = path.charAt(0) === '/' ? '/' : parse(path).root
10
+ path = path.substr(root.length)
11
+ r += root
12
+ }
13
+ return [r, path]
14
+ }
package/lib/unpack.js CHANGED
@@ -14,6 +14,7 @@ const path = require('path')
14
14
  const mkdir = require('./mkdir.js')
15
15
  const wc = require('./winchars.js')
16
16
  const pathReservations = require('./path-reservations.js')
17
+ const stripAbsolutePath = require('./strip-absolute-path.js')
17
18
 
18
19
  const ONENTRY = Symbol('onEntry')
19
20
  const CHECKFS = Symbol('checkFs')
@@ -224,11 +225,10 @@ class Unpack extends Parser {
224
225
 
225
226
  // absolutes on posix are also absolutes on win32
226
227
  // so we only need to test this one to get both
227
- if (path.win32.isAbsolute(p)) {
228
- const parsed = path.win32.parse(p)
229
- entry.path = p.substr(parsed.root.length)
230
- const r = parsed.root
231
- this.warn('TAR_ENTRY_INFO', `stripping ${r} from absolute path`, {
228
+ const [root, stripped] = stripAbsolutePath(p)
229
+ if (root) {
230
+ entry.path = stripped
231
+ this.warn('TAR_ENTRY_INFO', `stripping ${root} from absolute path`, {
232
232
  entry,
233
233
  path: p,
234
234
  })
@@ -23,6 +23,7 @@ const CLOSE = Symbol('close')
23
23
  const MODE = Symbol('mode')
24
24
  const warner = require('./warn-mixin.js')
25
25
  const winchars = require('./winchars.js')
26
+ const stripAbsolutePath = require('./strip-absolute-path.js')
26
27
 
27
28
  const modeFix = require('./mode-fix.js')
28
29
 
@@ -52,12 +53,12 @@ const WriteEntry = warner(class WriteEntry extends MiniPass {
52
53
  this.on('warn', opt.onwarn)
53
54
 
54
55
  let pathWarn = false
55
- if (!this.preservePaths && path.win32.isAbsolute(p)) {
56
- // absolutes on posix are also absolutes on win32
57
- // so we only need to test this one to get both
58
- const parsed = path.win32.parse(p)
59
- this.path = p.substr(parsed.root.length)
60
- pathWarn = parsed.root
56
+ if (!this.preservePaths) {
57
+ const [root, stripped] = stripAbsolutePath(this.path)
58
+ if (root) {
59
+ this.path = stripped
60
+ pathWarn = root
61
+ }
61
62
  }
62
63
 
63
64
  this.win32 = !!opt.win32 || process.platform === 'win32'
@@ -351,10 +352,12 @@ const WriteEntryTar = warner(class WriteEntryTar extends MiniPass {
351
352
  this.on('warn', opt.onwarn)
352
353
 
353
354
  let pathWarn = false
354
- if (path.isAbsolute(this.path) && !this.preservePaths) {
355
- const parsed = path.parse(this.path)
356
- pathWarn = parsed.root
357
- this.path = this.path.substr(parsed.root.length)
355
+ if (!this.preservePaths) {
356
+ const [root, stripped] = stripAbsolutePath(this.path)
357
+ if (root) {
358
+ this.path = stripped
359
+ pathWarn = root
360
+ }
358
361
  }
359
362
 
360
363
  this.remain = readEntry.size
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": "6.1.0",
5
+ "version": "6.1.1",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/npm/node-tar.git"
@@ -38,7 +38,7 @@
38
38
  "events-to-array": "^1.1.2",
39
39
  "mutate-fs": "^2.1.1",
40
40
  "rimraf": "^2.7.1",
41
- "tap": "^14.9.2",
41
+ "tap": "^15.0.9",
42
42
  "tar-fs": "^1.16.3",
43
43
  "tar-stream": "^1.6.2"
44
44
  },
package/CHANGELOG.md DELETED
@@ -1,68 +0,0 @@
1
- # Changelog
2
-
3
- ## 6.0
4
-
5
- - Drop support for node 6 and 8
6
- - fix symlinks and hardlinks on windows being packed with `\`-style path
7
- targets
8
-
9
- ## 5.0
10
-
11
- - Address unpack race conditions using path reservations
12
- - Change large-numbers errors from TypeError to Error
13
- - Add `TAR_*` error codes
14
- - Raise `TAR_BAD_ARCHIVE` warning/error when there are no valid entries
15
- found in an archive
16
- - do not treat ignored entries as an invalid archive
17
- - drop support for node v4
18
- - unpack: conditionally use a file mapping to write files on Windows
19
- - Set more portable 'mode' value in portable mode
20
- - Set `portable` gzip option in portable mode
21
-
22
- ## 4.4
23
-
24
- - Add 'mtime' option to tar creation to force mtime
25
- - unpack: only reuse file fs entries if nlink = 1
26
- - unpack: rename before unlinking files on Windows
27
- - Fix encoding/decoding of base-256 numbers
28
- - Use `stat` instead of `lstat` when checking CWD
29
- - Always provide a callback to fs.close()
30
-
31
- ## 4.3
32
-
33
- - Add 'transform' unpack option
34
-
35
- ## 4.2
36
-
37
- - Fail when zlib fails
38
-
39
- ## 4.1
40
-
41
- - Add noMtime flag for tar creation
42
-
43
- ## 4.0
44
-
45
- - unpack: raise error if cwd is missing or not a dir
46
- - pack: don't drop dots from dotfiles when prefixing
47
-
48
- ## 3.1
49
-
50
- - Support `@file.tar` as an entry argument to copy entries from one tar
51
- file to another.
52
- - Add `noPax` option
53
- - `noResume` option for tar.t
54
- - win32: convert `>|<?:` chars to windows-friendly form
55
- - Exclude mtime for dirs in portable mode
56
-
57
- ## 3.0
58
-
59
- - Minipass-based implementation
60
- - Entirely new API surface, `tar.c()`, `tar.x()` etc., much closer to
61
- system tar semantics
62
- - Massive performance improvement
63
- - Require node 4.x and higher
64
-
65
- ## 0.x, 1.x, 2.x - 2011-2014
66
-
67
- - fstream-based implementation
68
- - slow and kinda bad, but better than npm shelling out to the system `tar`