tar 6.2.1 → 7.0.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.
- package/README.md +30 -16
- package/dist/commonjs/create.d.ts +8 -0
- package/dist/commonjs/create.d.ts.map +1 -0
- package/dist/commonjs/create.js +106 -0
- package/dist/commonjs/create.js.map +1 -0
- package/dist/commonjs/cwd-error.d.ts +8 -0
- package/dist/commonjs/cwd-error.d.ts.map +1 -0
- package/dist/commonjs/cwd-error.js +18 -0
- package/dist/commonjs/cwd-error.js.map +1 -0
- package/dist/commonjs/extract.d.ts +8 -0
- package/dist/commonjs/extract.d.ts.map +1 -0
- package/dist/commonjs/extract.js +141 -0
- package/dist/commonjs/extract.js.map +1 -0
- package/dist/commonjs/get-write-flag.d.ts +2 -0
- package/dist/commonjs/get-write-flag.d.ts.map +1 -0
- package/dist/commonjs/get-write-flag.js +29 -0
- package/dist/commonjs/get-write-flag.js.map +1 -0
- package/dist/commonjs/header.d.ts +54 -0
- package/dist/commonjs/header.d.ts.map +1 -0
- package/dist/commonjs/header.js +311 -0
- package/dist/commonjs/header.js.map +1 -0
- package/dist/commonjs/index.d.ts +19 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +54 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/large-numbers.d.ts +4 -0
- package/dist/commonjs/large-numbers.d.ts.map +1 -0
- package/dist/commonjs/large-numbers.js +99 -0
- package/dist/commonjs/large-numbers.js.map +1 -0
- package/dist/commonjs/list.d.ts +8 -0
- package/dist/commonjs/list.d.ts.map +1 -0
- package/dist/commonjs/list.js +167 -0
- package/dist/commonjs/list.js.map +1 -0
- package/dist/commonjs/mkdir.d.ts +27 -0
- package/dist/commonjs/mkdir.d.ts.map +1 -0
- package/dist/commonjs/mkdir.js +209 -0
- package/dist/commonjs/mkdir.js.map +1 -0
- package/dist/commonjs/mode-fix.d.ts +2 -0
- package/dist/commonjs/mode-fix.d.ts.map +1 -0
- package/dist/commonjs/mode-fix.js +29 -0
- package/dist/commonjs/mode-fix.js.map +1 -0
- package/dist/commonjs/normalize-unicode.d.ts +2 -0
- package/dist/commonjs/normalize-unicode.d.ts.map +1 -0
- package/dist/commonjs/normalize-unicode.js +17 -0
- package/dist/commonjs/normalize-unicode.js.map +1 -0
- package/dist/commonjs/normalize-windows-path.d.ts +2 -0
- package/dist/commonjs/normalize-windows-path.d.ts.map +1 -0
- package/dist/commonjs/normalize-windows-path.js +12 -0
- package/dist/commonjs/normalize-windows-path.js.map +1 -0
- package/dist/commonjs/options.d.ts +545 -0
- package/dist/commonjs/options.d.ts.map +1 -0
- package/dist/commonjs/options.js +55 -0
- package/dist/commonjs/options.js.map +1 -0
- package/dist/commonjs/pack.d.ts +98 -0
- package/dist/commonjs/pack.d.ts.map +1 -0
- package/dist/commonjs/pack.js +461 -0
- package/dist/commonjs/pack.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/parse.d.ts +84 -0
- package/dist/commonjs/parse.d.ts.map +1 -0
- package/dist/commonjs/parse.js +571 -0
- package/dist/commonjs/parse.js.map +1 -0
- package/dist/commonjs/path-reservations.d.ts +11 -0
- package/dist/commonjs/path-reservations.d.ts.map +1 -0
- package/dist/commonjs/path-reservations.js +169 -0
- package/dist/commonjs/path-reservations.js.map +1 -0
- package/dist/commonjs/pax.d.ts +27 -0
- package/dist/commonjs/pax.d.ts.map +1 -0
- package/dist/commonjs/pax.js +158 -0
- package/dist/commonjs/pax.js.map +1 -0
- package/dist/commonjs/read-entry.d.ts +37 -0
- package/dist/commonjs/read-entry.d.ts.map +1 -0
- package/dist/commonjs/read-entry.js +139 -0
- package/dist/commonjs/read-entry.js.map +1 -0
- package/dist/commonjs/replace.d.ts +5 -0
- package/dist/commonjs/replace.d.ts.map +1 -0
- package/dist/commonjs/replace.js +223 -0
- package/dist/commonjs/replace.js.map +1 -0
- package/dist/commonjs/strip-absolute-path.d.ts +2 -0
- package/dist/commonjs/strip-absolute-path.d.ts.map +1 -0
- package/dist/commonjs/strip-absolute-path.js +29 -0
- package/dist/commonjs/strip-absolute-path.js.map +1 -0
- package/dist/commonjs/strip-trailing-slashes.d.ts +2 -0
- package/dist/commonjs/strip-trailing-slashes.d.ts.map +1 -0
- package/dist/commonjs/strip-trailing-slashes.js +18 -0
- package/dist/commonjs/strip-trailing-slashes.js.map +1 -0
- package/dist/commonjs/symlink-error.d.ts +9 -0
- package/dist/commonjs/symlink-error.d.ts.map +1 -0
- package/dist/commonjs/symlink-error.js +19 -0
- package/dist/commonjs/symlink-error.js.map +1 -0
- package/dist/commonjs/types.d.ts +7 -0
- package/dist/commonjs/types.d.ts.map +1 -0
- package/dist/commonjs/types.js +50 -0
- package/dist/commonjs/types.js.map +1 -0
- package/dist/commonjs/unpack.d.ts +98 -0
- package/dist/commonjs/unpack.d.ts.map +1 -0
- package/dist/commonjs/unpack.js +921 -0
- package/dist/commonjs/unpack.js.map +1 -0
- package/dist/commonjs/update.d.ts +3 -0
- package/dist/commonjs/update.d.ts.map +1 -0
- package/dist/commonjs/update.js +47 -0
- package/dist/commonjs/update.js.map +1 -0
- package/dist/commonjs/warn-method.d.ts +20 -0
- package/dist/commonjs/warn-method.d.ts.map +1 -0
- package/dist/commonjs/warn-method.js +31 -0
- package/dist/commonjs/warn-method.js.map +1 -0
- package/dist/commonjs/winchars.d.ts +3 -0
- package/dist/commonjs/winchars.d.ts.map +1 -0
- package/dist/commonjs/winchars.js +14 -0
- package/dist/commonjs/winchars.js.map +1 -0
- package/dist/commonjs/write-entry.d.ts +125 -0
- package/dist/commonjs/write-entry.d.ts.map +1 -0
- package/dist/commonjs/write-entry.js +657 -0
- package/dist/commonjs/write-entry.js.map +1 -0
- package/dist/esm/create.d.ts +8 -0
- package/dist/esm/create.d.ts.map +1 -0
- package/dist/esm/create.js +99 -0
- package/dist/esm/create.js.map +1 -0
- package/dist/esm/cwd-error.d.ts +8 -0
- package/dist/esm/cwd-error.d.ts.map +1 -0
- package/dist/esm/cwd-error.js +14 -0
- package/dist/esm/cwd-error.js.map +1 -0
- package/dist/esm/extract.d.ts +8 -0
- package/dist/esm/extract.d.ts.map +1 -0
- package/dist/esm/extract.js +111 -0
- package/dist/esm/extract.js.map +1 -0
- package/dist/esm/get-write-flag.d.ts +2 -0
- package/dist/esm/get-write-flag.d.ts.map +1 -0
- package/dist/esm/get-write-flag.js +23 -0
- package/dist/esm/get-write-flag.js.map +1 -0
- package/dist/esm/header.d.ts +54 -0
- package/dist/esm/header.d.ts.map +1 -0
- package/dist/esm/header.js +284 -0
- package/dist/esm/header.js.map +1 -0
- package/dist/esm/index.d.ts +19 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +20 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/large-numbers.d.ts +4 -0
- package/dist/esm/large-numbers.d.ts.map +1 -0
- package/dist/esm/large-numbers.js +94 -0
- package/dist/esm/large-numbers.js.map +1 -0
- package/dist/esm/list.d.ts +8 -0
- package/dist/esm/list.d.ts.map +1 -0
- package/dist/esm/list.js +137 -0
- package/dist/esm/list.js.map +1 -0
- package/dist/esm/mkdir.d.ts +27 -0
- package/dist/esm/mkdir.d.ts.map +1 -0
- package/dist/esm/mkdir.js +201 -0
- package/dist/esm/mkdir.js.map +1 -0
- package/dist/esm/mode-fix.d.ts +2 -0
- package/dist/esm/mode-fix.d.ts.map +1 -0
- package/dist/esm/mode-fix.js +25 -0
- package/dist/esm/mode-fix.js.map +1 -0
- package/dist/esm/normalize-unicode.d.ts +2 -0
- package/dist/esm/normalize-unicode.d.ts.map +1 -0
- package/dist/esm/normalize-unicode.js +13 -0
- package/dist/esm/normalize-unicode.js.map +1 -0
- package/dist/esm/normalize-windows-path.d.ts +2 -0
- package/dist/esm/normalize-windows-path.d.ts.map +1 -0
- package/{lib → dist/esm}/normalize-windows-path.js +5 -4
- package/dist/esm/normalize-windows-path.js.map +1 -0
- package/dist/esm/options.d.ts +545 -0
- package/dist/esm/options.d.ts.map +1 -0
- package/dist/esm/options.js +48 -0
- package/dist/esm/options.js.map +1 -0
- package/dist/esm/pack.d.ts +98 -0
- package/dist/esm/pack.d.ts.map +1 -0
- package/dist/esm/pack.js +429 -0
- package/dist/esm/pack.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/parse.d.ts +84 -0
- package/dist/esm/parse.d.ts.map +1 -0
- package/dist/esm/parse.js +567 -0
- package/dist/esm/parse.js.map +1 -0
- package/dist/esm/path-reservations.d.ts +11 -0
- package/dist/esm/path-reservations.d.ts.map +1 -0
- package/dist/esm/path-reservations.js +165 -0
- package/dist/esm/path-reservations.js.map +1 -0
- package/dist/esm/pax.d.ts +27 -0
- package/dist/esm/pax.d.ts.map +1 -0
- package/dist/esm/pax.js +154 -0
- package/dist/esm/pax.js.map +1 -0
- package/dist/esm/read-entry.d.ts +37 -0
- package/dist/esm/read-entry.d.ts.map +1 -0
- package/dist/esm/read-entry.js +135 -0
- package/dist/esm/read-entry.js.map +1 -0
- package/dist/esm/replace.d.ts +5 -0
- package/dist/esm/replace.d.ts.map +1 -0
- package/dist/esm/replace.js +216 -0
- package/dist/esm/replace.js.map +1 -0
- package/dist/esm/strip-absolute-path.d.ts +2 -0
- package/dist/esm/strip-absolute-path.d.ts.map +1 -0
- package/dist/esm/strip-absolute-path.js +25 -0
- package/dist/esm/strip-absolute-path.js.map +1 -0
- package/dist/esm/strip-trailing-slashes.d.ts +2 -0
- package/dist/esm/strip-trailing-slashes.d.ts.map +1 -0
- package/dist/esm/strip-trailing-slashes.js +14 -0
- package/dist/esm/strip-trailing-slashes.js.map +1 -0
- package/dist/esm/symlink-error.d.ts +9 -0
- package/dist/esm/symlink-error.d.ts.map +1 -0
- package/dist/esm/symlink-error.js +15 -0
- package/dist/esm/symlink-error.js.map +1 -0
- package/dist/esm/types.d.ts +7 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +45 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/unpack.d.ts +98 -0
- package/dist/esm/unpack.d.ts.map +1 -0
- package/dist/esm/unpack.js +890 -0
- package/dist/esm/unpack.js.map +1 -0
- package/dist/esm/update.d.ts +3 -0
- package/dist/esm/update.d.ts.map +1 -0
- package/dist/esm/update.js +43 -0
- package/dist/esm/update.js.map +1 -0
- package/dist/esm/warn-method.d.ts +20 -0
- package/dist/esm/warn-method.d.ts.map +1 -0
- package/dist/esm/warn-method.js +27 -0
- package/dist/esm/warn-method.js.map +1 -0
- package/dist/esm/winchars.d.ts +3 -0
- package/dist/esm/winchars.d.ts.map +1 -0
- package/dist/esm/winchars.js +9 -0
- package/dist/esm/winchars.js.map +1 -0
- package/dist/esm/write-entry.d.ts +125 -0
- package/dist/esm/write-entry.d.ts.map +1 -0
- package/dist/esm/write-entry.js +625 -0
- package/dist/esm/write-entry.js.map +1 -0
- package/package.json +255 -40
- package/index.js +0 -18
- package/lib/create.js +0 -111
- package/lib/extract.js +0 -113
- package/lib/get-write-flag.js +0 -20
- package/lib/header.js +0 -304
- package/lib/high-level-opt.js +0 -29
- package/lib/large-numbers.js +0 -104
- package/lib/list.js +0 -139
- package/lib/mkdir.js +0 -229
- package/lib/mode-fix.js +0 -27
- package/lib/normalize-unicode.js +0 -12
- package/lib/pack.js +0 -432
- package/lib/parse.js +0 -552
- package/lib/path-reservations.js +0 -156
- package/lib/pax.js +0 -150
- package/lib/read-entry.js +0 -107
- package/lib/replace.js +0 -246
- package/lib/strip-absolute-path.js +0 -24
- package/lib/strip-trailing-slashes.js +0 -13
- package/lib/types.js +0 -44
- package/lib/unpack.js +0 -923
- package/lib/update.js +0 -40
- package/lib/warn-mixin.js +0 -24
- package/lib/winchars.js +0 -23
- package/lib/write-entry.js +0 -546
package/lib/mkdir.js
DELETED
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
// wrapper around mkdirp for tar's needs.
|
|
3
|
-
|
|
4
|
-
// TODO: This should probably be a class, not functionally
|
|
5
|
-
// passing around state in a gazillion args.
|
|
6
|
-
|
|
7
|
-
const mkdirp = require('mkdirp')
|
|
8
|
-
const fs = require('fs')
|
|
9
|
-
const path = require('path')
|
|
10
|
-
const chownr = require('chownr')
|
|
11
|
-
const normPath = require('./normalize-windows-path.js')
|
|
12
|
-
|
|
13
|
-
class SymlinkError extends Error {
|
|
14
|
-
constructor (symlink, path) {
|
|
15
|
-
super('Cannot extract through symbolic link')
|
|
16
|
-
this.path = path
|
|
17
|
-
this.symlink = symlink
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
get name () {
|
|
21
|
-
return 'SylinkError'
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
class CwdError extends Error {
|
|
26
|
-
constructor (path, code) {
|
|
27
|
-
super(code + ': Cannot cd into \'' + path + '\'')
|
|
28
|
-
this.path = path
|
|
29
|
-
this.code = code
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
get name () {
|
|
33
|
-
return 'CwdError'
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const cGet = (cache, key) => cache.get(normPath(key))
|
|
38
|
-
const cSet = (cache, key, val) => cache.set(normPath(key), val)
|
|
39
|
-
|
|
40
|
-
const checkCwd = (dir, cb) => {
|
|
41
|
-
fs.stat(dir, (er, st) => {
|
|
42
|
-
if (er || !st.isDirectory()) {
|
|
43
|
-
er = new CwdError(dir, er && er.code || 'ENOTDIR')
|
|
44
|
-
}
|
|
45
|
-
cb(er)
|
|
46
|
-
})
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
module.exports = (dir, opt, cb) => {
|
|
50
|
-
dir = normPath(dir)
|
|
51
|
-
|
|
52
|
-
// if there's any overlap between mask and mode,
|
|
53
|
-
// then we'll need an explicit chmod
|
|
54
|
-
const umask = opt.umask
|
|
55
|
-
const mode = opt.mode | 0o0700
|
|
56
|
-
const needChmod = (mode & umask) !== 0
|
|
57
|
-
|
|
58
|
-
const uid = opt.uid
|
|
59
|
-
const gid = opt.gid
|
|
60
|
-
const doChown = typeof uid === 'number' &&
|
|
61
|
-
typeof gid === 'number' &&
|
|
62
|
-
(uid !== opt.processUid || gid !== opt.processGid)
|
|
63
|
-
|
|
64
|
-
const preserve = opt.preserve
|
|
65
|
-
const unlink = opt.unlink
|
|
66
|
-
const cache = opt.cache
|
|
67
|
-
const cwd = normPath(opt.cwd)
|
|
68
|
-
|
|
69
|
-
const done = (er, created) => {
|
|
70
|
-
if (er) {
|
|
71
|
-
cb(er)
|
|
72
|
-
} else {
|
|
73
|
-
cSet(cache, dir, true)
|
|
74
|
-
if (created && doChown) {
|
|
75
|
-
chownr(created, uid, gid, er => done(er))
|
|
76
|
-
} else if (needChmod) {
|
|
77
|
-
fs.chmod(dir, mode, cb)
|
|
78
|
-
} else {
|
|
79
|
-
cb()
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (cache && cGet(cache, dir) === true) {
|
|
85
|
-
return done()
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (dir === cwd) {
|
|
89
|
-
return checkCwd(dir, done)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (preserve) {
|
|
93
|
-
return mkdirp(dir, { mode }).then(made => done(null, made), done)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const sub = normPath(path.relative(cwd, dir))
|
|
97
|
-
const parts = sub.split('/')
|
|
98
|
-
mkdir_(cwd, parts, mode, cache, unlink, cwd, null, done)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const mkdir_ = (base, parts, mode, cache, unlink, cwd, created, cb) => {
|
|
102
|
-
if (!parts.length) {
|
|
103
|
-
return cb(null, created)
|
|
104
|
-
}
|
|
105
|
-
const p = parts.shift()
|
|
106
|
-
const part = normPath(path.resolve(base + '/' + p))
|
|
107
|
-
if (cGet(cache, part)) {
|
|
108
|
-
return mkdir_(part, parts, mode, cache, unlink, cwd, created, cb)
|
|
109
|
-
}
|
|
110
|
-
fs.mkdir(part, mode, onmkdir(part, parts, mode, cache, unlink, cwd, created, cb))
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const onmkdir = (part, parts, mode, cache, unlink, cwd, created, cb) => er => {
|
|
114
|
-
if (er) {
|
|
115
|
-
fs.lstat(part, (statEr, st) => {
|
|
116
|
-
if (statEr) {
|
|
117
|
-
statEr.path = statEr.path && normPath(statEr.path)
|
|
118
|
-
cb(statEr)
|
|
119
|
-
} else if (st.isDirectory()) {
|
|
120
|
-
mkdir_(part, parts, mode, cache, unlink, cwd, created, cb)
|
|
121
|
-
} else if (unlink) {
|
|
122
|
-
fs.unlink(part, er => {
|
|
123
|
-
if (er) {
|
|
124
|
-
return cb(er)
|
|
125
|
-
}
|
|
126
|
-
fs.mkdir(part, mode, onmkdir(part, parts, mode, cache, unlink, cwd, created, cb))
|
|
127
|
-
})
|
|
128
|
-
} else if (st.isSymbolicLink()) {
|
|
129
|
-
return cb(new SymlinkError(part, part + '/' + parts.join('/')))
|
|
130
|
-
} else {
|
|
131
|
-
cb(er)
|
|
132
|
-
}
|
|
133
|
-
})
|
|
134
|
-
} else {
|
|
135
|
-
created = created || part
|
|
136
|
-
mkdir_(part, parts, mode, cache, unlink, cwd, created, cb)
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const checkCwdSync = dir => {
|
|
141
|
-
let ok = false
|
|
142
|
-
let code = 'ENOTDIR'
|
|
143
|
-
try {
|
|
144
|
-
ok = fs.statSync(dir).isDirectory()
|
|
145
|
-
} catch (er) {
|
|
146
|
-
code = er.code
|
|
147
|
-
} finally {
|
|
148
|
-
if (!ok) {
|
|
149
|
-
throw new CwdError(dir, code)
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
module.exports.sync = (dir, opt) => {
|
|
155
|
-
dir = normPath(dir)
|
|
156
|
-
// if there's any overlap between mask and mode,
|
|
157
|
-
// then we'll need an explicit chmod
|
|
158
|
-
const umask = opt.umask
|
|
159
|
-
const mode = opt.mode | 0o0700
|
|
160
|
-
const needChmod = (mode & umask) !== 0
|
|
161
|
-
|
|
162
|
-
const uid = opt.uid
|
|
163
|
-
const gid = opt.gid
|
|
164
|
-
const doChown = typeof uid === 'number' &&
|
|
165
|
-
typeof gid === 'number' &&
|
|
166
|
-
(uid !== opt.processUid || gid !== opt.processGid)
|
|
167
|
-
|
|
168
|
-
const preserve = opt.preserve
|
|
169
|
-
const unlink = opt.unlink
|
|
170
|
-
const cache = opt.cache
|
|
171
|
-
const cwd = normPath(opt.cwd)
|
|
172
|
-
|
|
173
|
-
const done = (created) => {
|
|
174
|
-
cSet(cache, dir, true)
|
|
175
|
-
if (created && doChown) {
|
|
176
|
-
chownr.sync(created, uid, gid)
|
|
177
|
-
}
|
|
178
|
-
if (needChmod) {
|
|
179
|
-
fs.chmodSync(dir, mode)
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (cache && cGet(cache, dir) === true) {
|
|
184
|
-
return done()
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (dir === cwd) {
|
|
188
|
-
checkCwdSync(cwd)
|
|
189
|
-
return done()
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (preserve) {
|
|
193
|
-
return done(mkdirp.sync(dir, mode))
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
const sub = normPath(path.relative(cwd, dir))
|
|
197
|
-
const parts = sub.split('/')
|
|
198
|
-
let created = null
|
|
199
|
-
for (let p = parts.shift(), part = cwd;
|
|
200
|
-
p && (part += '/' + p);
|
|
201
|
-
p = parts.shift()) {
|
|
202
|
-
part = normPath(path.resolve(part))
|
|
203
|
-
if (cGet(cache, part)) {
|
|
204
|
-
continue
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
try {
|
|
208
|
-
fs.mkdirSync(part, mode)
|
|
209
|
-
created = created || part
|
|
210
|
-
cSet(cache, part, true)
|
|
211
|
-
} catch (er) {
|
|
212
|
-
const st = fs.lstatSync(part)
|
|
213
|
-
if (st.isDirectory()) {
|
|
214
|
-
cSet(cache, part, true)
|
|
215
|
-
continue
|
|
216
|
-
} else if (unlink) {
|
|
217
|
-
fs.unlinkSync(part)
|
|
218
|
-
fs.mkdirSync(part, mode)
|
|
219
|
-
created = created || part
|
|
220
|
-
cSet(cache, part, true)
|
|
221
|
-
continue
|
|
222
|
-
} else if (st.isSymbolicLink()) {
|
|
223
|
-
return new SymlinkError(part, part + '/' + parts.join('/'))
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
return done(created)
|
|
229
|
-
}
|
package/lib/mode-fix.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
module.exports = (mode, isDir, portable) => {
|
|
3
|
-
mode &= 0o7777
|
|
4
|
-
|
|
5
|
-
// in portable mode, use the minimum reasonable umask
|
|
6
|
-
// if this system creates files with 0o664 by default
|
|
7
|
-
// (as some linux distros do), then we'll write the
|
|
8
|
-
// archive with 0o644 instead. Also, don't ever create
|
|
9
|
-
// a file that is not readable/writable by the owner.
|
|
10
|
-
if (portable) {
|
|
11
|
-
mode = (mode | 0o600) & ~0o22
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// if dirs are readable, then they should be listable
|
|
15
|
-
if (isDir) {
|
|
16
|
-
if (mode & 0o400) {
|
|
17
|
-
mode |= 0o100
|
|
18
|
-
}
|
|
19
|
-
if (mode & 0o40) {
|
|
20
|
-
mode |= 0o10
|
|
21
|
-
}
|
|
22
|
-
if (mode & 0o4) {
|
|
23
|
-
mode |= 0o1
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return mode
|
|
27
|
-
}
|
package/lib/normalize-unicode.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// warning: extremely hot code path.
|
|
2
|
-
// This has been meticulously optimized for use
|
|
3
|
-
// within npm install on large package trees.
|
|
4
|
-
// Do not edit without careful benchmarking.
|
|
5
|
-
const normalizeCache = Object.create(null)
|
|
6
|
-
const { hasOwnProperty } = Object.prototype
|
|
7
|
-
module.exports = s => {
|
|
8
|
-
if (!hasOwnProperty.call(normalizeCache, s)) {
|
|
9
|
-
normalizeCache[s] = s.normalize('NFD')
|
|
10
|
-
}
|
|
11
|
-
return normalizeCache[s]
|
|
12
|
-
}
|
package/lib/pack.js
DELETED
|
@@ -1,432 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
// A readable tar stream creator
|
|
4
|
-
// Technically, this is a transform stream that you write paths into,
|
|
5
|
-
// and tar format comes out of.
|
|
6
|
-
// The `add()` method is like `write()` but returns this,
|
|
7
|
-
// and end() return `this` as well, so you can
|
|
8
|
-
// do `new Pack(opt).add('files').add('dir').end().pipe(output)
|
|
9
|
-
// You could also do something like:
|
|
10
|
-
// streamOfPaths().pipe(new Pack()).pipe(new fs.WriteStream('out.tar'))
|
|
11
|
-
|
|
12
|
-
class PackJob {
|
|
13
|
-
constructor (path, absolute) {
|
|
14
|
-
this.path = path || './'
|
|
15
|
-
this.absolute = absolute
|
|
16
|
-
this.entry = null
|
|
17
|
-
this.stat = null
|
|
18
|
-
this.readdir = null
|
|
19
|
-
this.pending = false
|
|
20
|
-
this.ignore = false
|
|
21
|
-
this.piped = false
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const { Minipass } = require('minipass')
|
|
26
|
-
const zlib = require('minizlib')
|
|
27
|
-
const ReadEntry = require('./read-entry.js')
|
|
28
|
-
const WriteEntry = require('./write-entry.js')
|
|
29
|
-
const WriteEntrySync = WriteEntry.Sync
|
|
30
|
-
const WriteEntryTar = WriteEntry.Tar
|
|
31
|
-
const Yallist = require('yallist')
|
|
32
|
-
const EOF = Buffer.alloc(1024)
|
|
33
|
-
const ONSTAT = Symbol('onStat')
|
|
34
|
-
const ENDED = Symbol('ended')
|
|
35
|
-
const QUEUE = Symbol('queue')
|
|
36
|
-
const CURRENT = Symbol('current')
|
|
37
|
-
const PROCESS = Symbol('process')
|
|
38
|
-
const PROCESSING = Symbol('processing')
|
|
39
|
-
const PROCESSJOB = Symbol('processJob')
|
|
40
|
-
const JOBS = Symbol('jobs')
|
|
41
|
-
const JOBDONE = Symbol('jobDone')
|
|
42
|
-
const ADDFSENTRY = Symbol('addFSEntry')
|
|
43
|
-
const ADDTARENTRY = Symbol('addTarEntry')
|
|
44
|
-
const STAT = Symbol('stat')
|
|
45
|
-
const READDIR = Symbol('readdir')
|
|
46
|
-
const ONREADDIR = Symbol('onreaddir')
|
|
47
|
-
const PIPE = Symbol('pipe')
|
|
48
|
-
const ENTRY = Symbol('entry')
|
|
49
|
-
const ENTRYOPT = Symbol('entryOpt')
|
|
50
|
-
const WRITEENTRYCLASS = Symbol('writeEntryClass')
|
|
51
|
-
const WRITE = Symbol('write')
|
|
52
|
-
const ONDRAIN = Symbol('ondrain')
|
|
53
|
-
|
|
54
|
-
const fs = require('fs')
|
|
55
|
-
const path = require('path')
|
|
56
|
-
const warner = require('./warn-mixin.js')
|
|
57
|
-
const normPath = require('./normalize-windows-path.js')
|
|
58
|
-
|
|
59
|
-
const Pack = warner(class Pack extends Minipass {
|
|
60
|
-
constructor (opt) {
|
|
61
|
-
super(opt)
|
|
62
|
-
opt = opt || Object.create(null)
|
|
63
|
-
this.opt = opt
|
|
64
|
-
this.file = opt.file || ''
|
|
65
|
-
this.cwd = opt.cwd || process.cwd()
|
|
66
|
-
this.maxReadSize = opt.maxReadSize
|
|
67
|
-
this.preservePaths = !!opt.preservePaths
|
|
68
|
-
this.strict = !!opt.strict
|
|
69
|
-
this.noPax = !!opt.noPax
|
|
70
|
-
this.prefix = normPath(opt.prefix || '')
|
|
71
|
-
this.linkCache = opt.linkCache || new Map()
|
|
72
|
-
this.statCache = opt.statCache || new Map()
|
|
73
|
-
this.readdirCache = opt.readdirCache || new Map()
|
|
74
|
-
|
|
75
|
-
this[WRITEENTRYCLASS] = WriteEntry
|
|
76
|
-
if (typeof opt.onwarn === 'function') {
|
|
77
|
-
this.on('warn', opt.onwarn)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
this.portable = !!opt.portable
|
|
81
|
-
this.zip = null
|
|
82
|
-
|
|
83
|
-
if (opt.gzip || opt.brotli) {
|
|
84
|
-
if (opt.gzip && opt.brotli) {
|
|
85
|
-
throw new TypeError('gzip and brotli are mutually exclusive')
|
|
86
|
-
}
|
|
87
|
-
if (opt.gzip) {
|
|
88
|
-
if (typeof opt.gzip !== 'object') {
|
|
89
|
-
opt.gzip = {}
|
|
90
|
-
}
|
|
91
|
-
if (this.portable) {
|
|
92
|
-
opt.gzip.portable = true
|
|
93
|
-
}
|
|
94
|
-
this.zip = new zlib.Gzip(opt.gzip)
|
|
95
|
-
}
|
|
96
|
-
if (opt.brotli) {
|
|
97
|
-
if (typeof opt.brotli !== 'object') {
|
|
98
|
-
opt.brotli = {}
|
|
99
|
-
}
|
|
100
|
-
this.zip = new zlib.BrotliCompress(opt.brotli)
|
|
101
|
-
}
|
|
102
|
-
this.zip.on('data', chunk => super.write(chunk))
|
|
103
|
-
this.zip.on('end', _ => super.end())
|
|
104
|
-
this.zip.on('drain', _ => this[ONDRAIN]())
|
|
105
|
-
this.on('resume', _ => this.zip.resume())
|
|
106
|
-
} else {
|
|
107
|
-
this.on('drain', this[ONDRAIN])
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
this.noDirRecurse = !!opt.noDirRecurse
|
|
111
|
-
this.follow = !!opt.follow
|
|
112
|
-
this.noMtime = !!opt.noMtime
|
|
113
|
-
this.mtime = opt.mtime || null
|
|
114
|
-
|
|
115
|
-
this.filter = typeof opt.filter === 'function' ? opt.filter : _ => true
|
|
116
|
-
|
|
117
|
-
this[QUEUE] = new Yallist()
|
|
118
|
-
this[JOBS] = 0
|
|
119
|
-
this.jobs = +opt.jobs || 4
|
|
120
|
-
this[PROCESSING] = false
|
|
121
|
-
this[ENDED] = false
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
[WRITE] (chunk) {
|
|
125
|
-
return super.write(chunk)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
add (path) {
|
|
129
|
-
this.write(path)
|
|
130
|
-
return this
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
end (path) {
|
|
134
|
-
if (path) {
|
|
135
|
-
this.write(path)
|
|
136
|
-
}
|
|
137
|
-
this[ENDED] = true
|
|
138
|
-
this[PROCESS]()
|
|
139
|
-
return this
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
write (path) {
|
|
143
|
-
if (this[ENDED]) {
|
|
144
|
-
throw new Error('write after end')
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (path instanceof ReadEntry) {
|
|
148
|
-
this[ADDTARENTRY](path)
|
|
149
|
-
} else {
|
|
150
|
-
this[ADDFSENTRY](path)
|
|
151
|
-
}
|
|
152
|
-
return this.flowing
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
[ADDTARENTRY] (p) {
|
|
156
|
-
const absolute = normPath(path.resolve(this.cwd, p.path))
|
|
157
|
-
// in this case, we don't have to wait for the stat
|
|
158
|
-
if (!this.filter(p.path, p)) {
|
|
159
|
-
p.resume()
|
|
160
|
-
} else {
|
|
161
|
-
const job = new PackJob(p.path, absolute, false)
|
|
162
|
-
job.entry = new WriteEntryTar(p, this[ENTRYOPT](job))
|
|
163
|
-
job.entry.on('end', _ => this[JOBDONE](job))
|
|
164
|
-
this[JOBS] += 1
|
|
165
|
-
this[QUEUE].push(job)
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
this[PROCESS]()
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
[ADDFSENTRY] (p) {
|
|
172
|
-
const absolute = normPath(path.resolve(this.cwd, p))
|
|
173
|
-
this[QUEUE].push(new PackJob(p, absolute))
|
|
174
|
-
this[PROCESS]()
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
[STAT] (job) {
|
|
178
|
-
job.pending = true
|
|
179
|
-
this[JOBS] += 1
|
|
180
|
-
const stat = this.follow ? 'stat' : 'lstat'
|
|
181
|
-
fs[stat](job.absolute, (er, stat) => {
|
|
182
|
-
job.pending = false
|
|
183
|
-
this[JOBS] -= 1
|
|
184
|
-
if (er) {
|
|
185
|
-
this.emit('error', er)
|
|
186
|
-
} else {
|
|
187
|
-
this[ONSTAT](job, stat)
|
|
188
|
-
}
|
|
189
|
-
})
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
[ONSTAT] (job, stat) {
|
|
193
|
-
this.statCache.set(job.absolute, stat)
|
|
194
|
-
job.stat = stat
|
|
195
|
-
|
|
196
|
-
// now we have the stat, we can filter it.
|
|
197
|
-
if (!this.filter(job.path, stat)) {
|
|
198
|
-
job.ignore = true
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
this[PROCESS]()
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
[READDIR] (job) {
|
|
205
|
-
job.pending = true
|
|
206
|
-
this[JOBS] += 1
|
|
207
|
-
fs.readdir(job.absolute, (er, entries) => {
|
|
208
|
-
job.pending = false
|
|
209
|
-
this[JOBS] -= 1
|
|
210
|
-
if (er) {
|
|
211
|
-
return this.emit('error', er)
|
|
212
|
-
}
|
|
213
|
-
this[ONREADDIR](job, entries)
|
|
214
|
-
})
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
[ONREADDIR] (job, entries) {
|
|
218
|
-
this.readdirCache.set(job.absolute, entries)
|
|
219
|
-
job.readdir = entries
|
|
220
|
-
this[PROCESS]()
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
[PROCESS] () {
|
|
224
|
-
if (this[PROCESSING]) {
|
|
225
|
-
return
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
this[PROCESSING] = true
|
|
229
|
-
for (let w = this[QUEUE].head;
|
|
230
|
-
w !== null && this[JOBS] < this.jobs;
|
|
231
|
-
w = w.next) {
|
|
232
|
-
this[PROCESSJOB](w.value)
|
|
233
|
-
if (w.value.ignore) {
|
|
234
|
-
const p = w.next
|
|
235
|
-
this[QUEUE].removeNode(w)
|
|
236
|
-
w.next = p
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
this[PROCESSING] = false
|
|
241
|
-
|
|
242
|
-
if (this[ENDED] && !this[QUEUE].length && this[JOBS] === 0) {
|
|
243
|
-
if (this.zip) {
|
|
244
|
-
this.zip.end(EOF)
|
|
245
|
-
} else {
|
|
246
|
-
super.write(EOF)
|
|
247
|
-
super.end()
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
get [CURRENT] () {
|
|
253
|
-
return this[QUEUE] && this[QUEUE].head && this[QUEUE].head.value
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
[JOBDONE] (job) {
|
|
257
|
-
this[QUEUE].shift()
|
|
258
|
-
this[JOBS] -= 1
|
|
259
|
-
this[PROCESS]()
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
[PROCESSJOB] (job) {
|
|
263
|
-
if (job.pending) {
|
|
264
|
-
return
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
if (job.entry) {
|
|
268
|
-
if (job === this[CURRENT] && !job.piped) {
|
|
269
|
-
this[PIPE](job)
|
|
270
|
-
}
|
|
271
|
-
return
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
if (!job.stat) {
|
|
275
|
-
if (this.statCache.has(job.absolute)) {
|
|
276
|
-
this[ONSTAT](job, this.statCache.get(job.absolute))
|
|
277
|
-
} else {
|
|
278
|
-
this[STAT](job)
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
if (!job.stat) {
|
|
282
|
-
return
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
// filtered out!
|
|
286
|
-
if (job.ignore) {
|
|
287
|
-
return
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
if (!this.noDirRecurse && job.stat.isDirectory() && !job.readdir) {
|
|
291
|
-
if (this.readdirCache.has(job.absolute)) {
|
|
292
|
-
this[ONREADDIR](job, this.readdirCache.get(job.absolute))
|
|
293
|
-
} else {
|
|
294
|
-
this[READDIR](job)
|
|
295
|
-
}
|
|
296
|
-
if (!job.readdir) {
|
|
297
|
-
return
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// we know it doesn't have an entry, because that got checked above
|
|
302
|
-
job.entry = this[ENTRY](job)
|
|
303
|
-
if (!job.entry) {
|
|
304
|
-
job.ignore = true
|
|
305
|
-
return
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
if (job === this[CURRENT] && !job.piped) {
|
|
309
|
-
this[PIPE](job)
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
[ENTRYOPT] (job) {
|
|
314
|
-
return {
|
|
315
|
-
onwarn: (code, msg, data) => this.warn(code, msg, data),
|
|
316
|
-
noPax: this.noPax,
|
|
317
|
-
cwd: this.cwd,
|
|
318
|
-
absolute: job.absolute,
|
|
319
|
-
preservePaths: this.preservePaths,
|
|
320
|
-
maxReadSize: this.maxReadSize,
|
|
321
|
-
strict: this.strict,
|
|
322
|
-
portable: this.portable,
|
|
323
|
-
linkCache: this.linkCache,
|
|
324
|
-
statCache: this.statCache,
|
|
325
|
-
noMtime: this.noMtime,
|
|
326
|
-
mtime: this.mtime,
|
|
327
|
-
prefix: this.prefix,
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
[ENTRY] (job) {
|
|
332
|
-
this[JOBS] += 1
|
|
333
|
-
try {
|
|
334
|
-
return new this[WRITEENTRYCLASS](job.path, this[ENTRYOPT](job))
|
|
335
|
-
.on('end', () => this[JOBDONE](job))
|
|
336
|
-
.on('error', er => this.emit('error', er))
|
|
337
|
-
} catch (er) {
|
|
338
|
-
this.emit('error', er)
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
[ONDRAIN] () {
|
|
343
|
-
if (this[CURRENT] && this[CURRENT].entry) {
|
|
344
|
-
this[CURRENT].entry.resume()
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
// like .pipe() but using super, because our write() is special
|
|
349
|
-
[PIPE] (job) {
|
|
350
|
-
job.piped = true
|
|
351
|
-
|
|
352
|
-
if (job.readdir) {
|
|
353
|
-
job.readdir.forEach(entry => {
|
|
354
|
-
const p = job.path
|
|
355
|
-
const base = p === './' ? '' : p.replace(/\/*$/, '/')
|
|
356
|
-
this[ADDFSENTRY](base + entry)
|
|
357
|
-
})
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
const source = job.entry
|
|
361
|
-
const zip = this.zip
|
|
362
|
-
|
|
363
|
-
if (zip) {
|
|
364
|
-
source.on('data', chunk => {
|
|
365
|
-
if (!zip.write(chunk)) {
|
|
366
|
-
source.pause()
|
|
367
|
-
}
|
|
368
|
-
})
|
|
369
|
-
} else {
|
|
370
|
-
source.on('data', chunk => {
|
|
371
|
-
if (!super.write(chunk)) {
|
|
372
|
-
source.pause()
|
|
373
|
-
}
|
|
374
|
-
})
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
pause () {
|
|
379
|
-
if (this.zip) {
|
|
380
|
-
this.zip.pause()
|
|
381
|
-
}
|
|
382
|
-
return super.pause()
|
|
383
|
-
}
|
|
384
|
-
})
|
|
385
|
-
|
|
386
|
-
class PackSync extends Pack {
|
|
387
|
-
constructor (opt) {
|
|
388
|
-
super(opt)
|
|
389
|
-
this[WRITEENTRYCLASS] = WriteEntrySync
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
// pause/resume are no-ops in sync streams.
|
|
393
|
-
pause () {}
|
|
394
|
-
resume () {}
|
|
395
|
-
|
|
396
|
-
[STAT] (job) {
|
|
397
|
-
const stat = this.follow ? 'statSync' : 'lstatSync'
|
|
398
|
-
this[ONSTAT](job, fs[stat](job.absolute))
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
[READDIR] (job, stat) {
|
|
402
|
-
this[ONREADDIR](job, fs.readdirSync(job.absolute))
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
// gotta get it all in this tick
|
|
406
|
-
[PIPE] (job) {
|
|
407
|
-
const source = job.entry
|
|
408
|
-
const zip = this.zip
|
|
409
|
-
|
|
410
|
-
if (job.readdir) {
|
|
411
|
-
job.readdir.forEach(entry => {
|
|
412
|
-
const p = job.path
|
|
413
|
-
const base = p === './' ? '' : p.replace(/\/*$/, '/')
|
|
414
|
-
this[ADDFSENTRY](base + entry)
|
|
415
|
-
})
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
if (zip) {
|
|
419
|
-
source.on('data', chunk => {
|
|
420
|
-
zip.write(chunk)
|
|
421
|
-
})
|
|
422
|
-
} else {
|
|
423
|
-
source.on('data', chunk => {
|
|
424
|
-
super[WRITE](chunk)
|
|
425
|
-
})
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
Pack.Sync = PackSync
|
|
431
|
-
|
|
432
|
-
module.exports = Pack
|