Skip to content

Commit 5730d17

Browse files
committed
deps: tar@6.1.12
1 parent 2fef570 commit 5730d17

22 files changed

+589
-357
lines changed

node_modules/tar/lib/create.js

+16-9
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,29 @@ const t = require('./list.js')
99
const path = require('path')
1010

1111
module.exports = (opt_, files, cb) => {
12-
if (typeof files === 'function')
12+
if (typeof files === 'function') {
1313
cb = files
14+
}
1415

15-
if (Array.isArray(opt_))
16+
if (Array.isArray(opt_)) {
1617
files = opt_, opt_ = {}
18+
}
1719

18-
if (!files || !Array.isArray(files) || !files.length)
20+
if (!files || !Array.isArray(files) || !files.length) {
1921
throw new TypeError('no files or directories specified')
22+
}
2023

2124
files = Array.from(files)
2225

2326
const opt = hlo(opt_)
2427

25-
if (opt.sync && typeof cb === 'function')
28+
if (opt.sync && typeof cb === 'function') {
2629
throw new TypeError('callback not supported for sync tar functions')
30+
}
2731

28-
if (!opt.file && typeof cb === 'function')
32+
if (!opt.file && typeof cb === 'function') {
2933
throw new TypeError('callback only supported with file option')
34+
}
3035

3136
return opt.file && opt.sync ? createFileSync(opt, files)
3237
: opt.file ? createFile(opt, files, cb)
@@ -65,13 +70,14 @@ const addFilesSync = (p, files) => {
6570
files.forEach(file => {
6671
if (file.charAt(0) === '@') {
6772
t({
68-
file: path.resolve(p.cwd, file.substr(1)),
73+
file: path.resolve(p.cwd, file.slice(1)),
6974
sync: true,
7075
noResume: true,
7176
onentry: entry => p.add(entry),
7277
})
73-
} else
78+
} else {
7479
p.add(file)
80+
}
7581
})
7682
p.end()
7783
}
@@ -81,12 +87,13 @@ const addFilesAsync = (p, files) => {
8187
const file = files.shift()
8288
if (file.charAt(0) === '@') {
8389
return t({
84-
file: path.resolve(p.cwd, file.substr(1)),
90+
file: path.resolve(p.cwd, file.slice(1)),
8591
noResume: true,
8692
onentry: entry => p.add(entry),
8793
}).then(_ => addFilesAsync(p, files))
88-
} else
94+
} else {
8995
p.add(file)
96+
}
9097
}
9198
p.end()
9299
}

node_modules/tar/lib/extract.js

+16-10
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,35 @@ const path = require('path')
99
const stripSlash = require('./strip-trailing-slashes.js')
1010

1111
module.exports = (opt_, files, cb) => {
12-
if (typeof opt_ === 'function')
12+
if (typeof opt_ === 'function') {
1313
cb = opt_, files = null, opt_ = {}
14-
else if (Array.isArray(opt_))
14+
} else if (Array.isArray(opt_)) {
1515
files = opt_, opt_ = {}
16+
}
1617

17-
if (typeof files === 'function')
18+
if (typeof files === 'function') {
1819
cb = files, files = null
20+
}
1921

20-
if (!files)
22+
if (!files) {
2123
files = []
22-
else
24+
} else {
2325
files = Array.from(files)
26+
}
2427

2528
const opt = hlo(opt_)
2629

27-
if (opt.sync && typeof cb === 'function')
30+
if (opt.sync && typeof cb === 'function') {
2831
throw new TypeError('callback not supported for sync tar functions')
32+
}
2933

30-
if (!opt.file && typeof cb === 'function')
34+
if (!opt.file && typeof cb === 'function') {
3135
throw new TypeError('callback only supported with file option')
36+
}
3237

33-
if (files.length)
38+
if (files.length) {
3439
filesFilter(opt, files)
40+
}
3541

3642
return opt.file && opt.sync ? extractFileSync(opt)
3743
: opt.file ? extractFile(opt, cb)
@@ -87,9 +93,9 @@ const extractFile = (opt, cb) => {
8793
// This trades a zero-byte read() syscall for a stat
8894
// However, it will usually result in less memory allocation
8995
fs.stat(file, (er, stat) => {
90-
if (er)
96+
if (er) {
9197
reject(er)
92-
else {
98+
} else {
9399
const stream = new fsm.ReadStream(file, {
94100
readSize: readSize,
95101
size: stat.size,

node_modules/tar/lib/header.js

+50-34
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,21 @@ class Header {
3434
this.atime = null
3535
this.ctime = null
3636

37-
if (Buffer.isBuffer(data))
37+
if (Buffer.isBuffer(data)) {
3838
this.decode(data, off || 0, ex, gex)
39-
else if (data)
39+
} else if (data) {
4040
this.set(data)
41+
}
4142
}
4243

4344
decode (buf, off, ex, gex) {
44-
if (!off)
45+
if (!off) {
4546
off = 0
47+
}
4648

47-
if (!buf || !(buf.length >= off + 512))
49+
if (!buf || !(buf.length >= off + 512)) {
4850
throw new Error('need 512 bytes for header')
51+
}
4952

5053
this.path = decString(buf, off, 100)
5154
this.mode = decNumber(buf, off + 100, 8)
@@ -62,18 +65,21 @@ class Header {
6265

6366
// old tar versions marked dirs as a file with a trailing /
6467
this[TYPE] = decString(buf, off + 156, 1)
65-
if (this[TYPE] === '')
68+
if (this[TYPE] === '') {
6669
this[TYPE] = '0'
67-
if (this[TYPE] === '0' && this.path.substr(-1) === '/')
70+
}
71+
if (this[TYPE] === '0' && this.path.slice(-1) === '/') {
6872
this[TYPE] = '5'
73+
}
6974

7075
// tar implementations sometimes incorrectly put the stat(dir).size
7176
// as the size in the tarball, even though Directory entries are
7277
// not able to have any body at all. In the very rare chance that
7378
// it actually DOES have a body, we weren't going to do anything with
7479
// it anyway, and it'll just be a warning about an invalid header.
75-
if (this[TYPE] === '5')
80+
if (this[TYPE] === '5') {
7681
this.size = 0
82+
}
7783

7884
this.linkpath = decString(buf, off + 157, 100)
7985
if (buf.slice(off + 257, off + 265).toString() === 'ustar\u000000') {
@@ -87,32 +93,37 @@ class Header {
8793
this.path = prefix + '/' + this.path
8894
} else {
8995
const prefix = decString(buf, off + 345, 130)
90-
if (prefix)
96+
if (prefix) {
9197
this.path = prefix + '/' + this.path
98+
}
9299
this.atime = decDate(buf, off + 476, 12)
93100
this.ctime = decDate(buf, off + 488, 12)
94101
}
95102
}
96103

97104
let sum = 8 * 0x20
98-
for (let i = off; i < off + 148; i++)
105+
for (let i = off; i < off + 148; i++) {
99106
sum += buf[i]
107+
}
100108

101-
for (let i = off + 156; i < off + 512; i++)
109+
for (let i = off + 156; i < off + 512; i++) {
102110
sum += buf[i]
111+
}
103112

104113
this.cksumValid = sum === this.cksum
105-
if (this.cksum === null && sum === 8 * 0x20)
114+
if (this.cksum === null && sum === 8 * 0x20) {
106115
this.nullBlock = true
116+
}
107117
}
108118

109119
[SLURP] (ex, global) {
110120
for (const k in ex) {
111121
// we slurp in everything except for the path attribute in
112122
// a global extended header, because that's weird.
113123
if (ex[k] !== null && ex[k] !== undefined &&
114-
!(global && k === 'path'))
124+
!(global && k === 'path')) {
115125
this[k] = ex[k]
126+
}
116127
}
117128
}
118129

@@ -122,11 +133,13 @@ class Header {
122133
off = 0
123134
}
124135

125-
if (!off)
136+
if (!off) {
126137
off = 0
138+
}
127139

128-
if (!(buf.length >= off + 512))
140+
if (!(buf.length >= off + 512)) {
129141
throw new Error('need 512 bytes for header')
142+
}
130143

131144
const prefixSize = this.ctime || this.atime ? 130 : 155
132145
const split = splitPrefix(this.path || '', prefixSize)
@@ -148,20 +161,22 @@ class Header {
148161
this.needPax = encNumber(buf, off + 329, 8, this.devmaj) || this.needPax
149162
this.needPax = encNumber(buf, off + 337, 8, this.devmin) || this.needPax
150163
this.needPax = encString(buf, off + 345, prefixSize, prefix) || this.needPax
151-
if (buf[off + 475] !== 0)
164+
if (buf[off + 475] !== 0) {
152165
this.needPax = encString(buf, off + 345, 155, prefix) || this.needPax
153-
else {
166+
} else {
154167
this.needPax = encString(buf, off + 345, 130, prefix) || this.needPax
155168
this.needPax = encDate(buf, off + 476, 12, this.atime) || this.needPax
156169
this.needPax = encDate(buf, off + 488, 12, this.ctime) || this.needPax
157170
}
158171

159172
let sum = 8 * 0x20
160-
for (let i = off; i < off + 148; i++)
173+
for (let i = off; i < off + 148; i++) {
161174
sum += buf[i]
175+
}
162176

163-
for (let i = off + 156; i < off + 512; i++)
177+
for (let i = off + 156; i < off + 512; i++) {
164178
sum += buf[i]
179+
}
165180

166181
this.cksum = sum
167182
encNumber(buf, off + 148, 8, this.cksum)
@@ -172,8 +187,9 @@ class Header {
172187

173188
set (data) {
174189
for (const i in data) {
175-
if (data[i] !== null && data[i] !== undefined)
190+
if (data[i] !== null && data[i] !== undefined) {
176191
this[i] = data[i]
192+
}
177193
}
178194
}
179195

@@ -186,10 +202,11 @@ class Header {
186202
}
187203

188204
set type (type) {
189-
if (types.code.has(type))
205+
if (types.code.has(type)) {
190206
this[TYPE] = types.code.get(type)
191-
else
207+
} else {
192208
this[TYPE] = type
209+
}
193210
}
194211
}
195212

@@ -200,34 +217,33 @@ const splitPrefix = (p, prefixSize) => {
200217
let ret
201218
const root = pathModule.parse(p).root || '.'
202219

203-
if (Buffer.byteLength(pp) < pathSize)
220+
if (Buffer.byteLength(pp) < pathSize) {
204221
ret = [pp, prefix, false]
205-
else {
222+
} else {
206223
// first set prefix to the dir, and path to the base
207224
prefix = pathModule.dirname(pp)
208225
pp = pathModule.basename(pp)
209226

210227
do {
211-
// both fit!
212228
if (Buffer.byteLength(pp) <= pathSize &&
213-
Buffer.byteLength(prefix) <= prefixSize)
229+
Buffer.byteLength(prefix) <= prefixSize) {
230+
// both fit!
214231
ret = [pp, prefix, false]
215-
216-
// prefix fits in prefix, but path doesn't fit in path
217-
else if (Buffer.byteLength(pp) > pathSize &&
218-
Buffer.byteLength(prefix) <= prefixSize)
219-
ret = [pp.substr(0, pathSize - 1), prefix, true]
220-
221-
else {
232+
} else if (Buffer.byteLength(pp) > pathSize &&
233+
Buffer.byteLength(prefix) <= prefixSize) {
234+
// prefix fits in prefix, but path doesn't fit in path
235+
ret = [pp.slice(0, pathSize - 1), prefix, true]
236+
} else {
222237
// make path take a bit from prefix
223238
pp = pathModule.join(pathModule.basename(prefix), pp)
224239
prefix = pathModule.dirname(prefix)
225240
}
226241
} while (prefix !== root && !ret)
227242

228243
// at this point, found no resolution, just truncate
229-
if (!ret)
230-
ret = [p.substr(0, pathSize - 1), '', true]
244+
if (!ret) {
245+
ret = [p.slice(0, pathSize - 1), '', true]
246+
}
231247
}
232248
return ret
233249
}

0 commit comments

Comments
 (0)