muhammara 3.2.0 → 3.4.0

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +37 -2
  2. package/binding.gyp +2 -2
  3. package/muhammara.d.ts +1 -1
  4. package/node_modules/tar/README.md +37 -9
  5. package/node_modules/tar/lib/create.js +16 -9
  6. package/node_modules/tar/lib/extract.js +16 -10
  7. package/node_modules/tar/lib/header.js +50 -34
  8. package/node_modules/tar/lib/large-numbers.js +22 -17
  9. package/node_modules/tar/lib/list.js +20 -13
  10. package/node_modules/tar/lib/mkdir.js +40 -24
  11. package/node_modules/tar/lib/mode-fix.js +8 -4
  12. package/node_modules/tar/lib/normalize-unicode.js +3 -2
  13. package/node_modules/tar/lib/pack.js +54 -31
  14. package/node_modules/tar/lib/parse.js +74 -46
  15. package/node_modules/tar/lib/path-reservations.js +26 -18
  16. package/node_modules/tar/lib/pax.js +15 -8
  17. package/node_modules/tar/lib/read-entry.js +14 -7
  18. package/node_modules/tar/lib/replace.js +50 -27
  19. package/node_modules/tar/lib/strip-absolute-path.js +1 -1
  20. package/node_modules/tar/lib/unpack.js +73 -44
  21. package/node_modules/tar/lib/update.js +8 -4
  22. package/node_modules/tar/lib/warn-mixin.js +7 -4
  23. package/node_modules/tar/lib/write-entry.js +44 -23
  24. package/node_modules/tar/package.json +44 -30
  25. package/package.json +1 -1
  26. package/src/deps/FreeType/binding.gyp +10 -0
  27. package/src/deps/LibAesgm/binding.gyp +10 -0
  28. package/src/deps/LibJpeg/binding.gyp +10 -0
  29. package/src/deps/LibPng/binding.gyp +11 -1
  30. package/src/deps/LibTiff/binding.gyp +10 -0
  31. package/src/deps/PDFWriter/CFFFileInput.cpp +7 -1
  32. package/src/deps/PDFWriter/DecryptionHelper.cpp +1 -1
  33. package/src/deps/PDFWriter/DocumentContext.cpp +21 -8
  34. package/src/deps/PDFWriter/DocumentContext.h +1 -1
  35. package/src/deps/PDFWriter/PDFModifiedPage.cpp +2 -0
  36. package/src/deps/PDFWriter/PDFPageInput.cpp +7 -1
  37. package/src/deps/PDFWriter/PDFParser.cpp +6 -0
  38. package/src/deps/PDFWriter/PDFUsedFont.cpp +4 -2
  39. package/src/deps/PDFWriter/TrueTypeEmbeddedFontWriter.cpp +15 -0
  40. package/src/deps/PDFWriter/binding.gyp +10 -0
  41. package/src/deps/ZLib/binding.gyp +10 -0
@@ -19,14 +19,17 @@ const Header = require('./header.js')
19
19
  module.exports = (opt_, files, cb) => {
20
20
  const opt = hlo(opt_)
21
21
 
22
- if (!opt.file)
22
+ if (!opt.file) {
23
23
  throw new TypeError('file is required')
24
+ }
24
25
 
25
- if (opt.gzip)
26
+ if (opt.gzip) {
26
27
  throw new TypeError('cannot append to compressed archives')
28
+ }
27
29
 
28
- if (!files || !Array.isArray(files) || !files.length)
30
+ if (!files || !Array.isArray(files) || !files.length) {
29
31
  throw new TypeError('no files or directories specified')
32
+ }
30
33
 
31
34
  files = Array.from(files)
32
35
 
@@ -45,10 +48,11 @@ const replaceSync = (opt, files) => {
45
48
  try {
46
49
  fd = fs.openSync(opt.file, 'r+')
47
50
  } catch (er) {
48
- if (er.code === 'ENOENT')
51
+ if (er.code === 'ENOENT') {
49
52
  fd = fs.openSync(opt.file, 'w+')
50
- else
53
+ } else {
51
54
  throw er
55
+ }
52
56
  }
53
57
 
54
58
  const st = fs.fstatSync(fd)
@@ -60,24 +64,29 @@ const replaceSync = (opt, files) => {
60
64
  fd, headBuf, bufPos, headBuf.length - bufPos, position + bufPos
61
65
  )
62
66
 
63
- if (position === 0 && headBuf[0] === 0x1f && headBuf[1] === 0x8b)
67
+ if (position === 0 && headBuf[0] === 0x1f && headBuf[1] === 0x8b) {
64
68
  throw new Error('cannot append to compressed archives')
69
+ }
65
70
 
66
- if (!bytes)
71
+ if (!bytes) {
67
72
  break POSITION
73
+ }
68
74
  }
69
75
 
70
76
  const h = new Header(headBuf)
71
- if (!h.cksumValid)
77
+ if (!h.cksumValid) {
72
78
  break
79
+ }
73
80
  const entryBlockSize = 512 * Math.ceil(h.size / 512)
74
- if (position + entryBlockSize + 512 > st.size)
81
+ if (position + entryBlockSize + 512 > st.size) {
75
82
  break
83
+ }
76
84
  // the 512 for the header we just parsed will be added as well
77
85
  // also jump ahead all the blocks for the body
78
86
  position += entryBlockSize
79
- if (opt.mtimeCache)
87
+ if (opt.mtimeCache) {
80
88
  opt.mtimeCache.set(h.path, h.mtime)
89
+ }
81
90
  }
82
91
  threw = false
83
92
 
@@ -106,21 +115,24 @@ const replace = (opt, files, cb) => {
106
115
 
107
116
  const getPos = (fd, size, cb_) => {
108
117
  const cb = (er, pos) => {
109
- if (er)
118
+ if (er) {
110
119
  fs.close(fd, _ => cb_(er))
111
- else
120
+ } else {
112
121
  cb_(null, pos)
122
+ }
113
123
  }
114
124
 
115
125
  let position = 0
116
- if (size === 0)
126
+ if (size === 0) {
117
127
  return cb(null, 0)
128
+ }
118
129
 
119
130
  let bufPos = 0
120
131
  const headBuf = Buffer.alloc(512)
121
132
  const onread = (er, bytes) => {
122
- if (er)
133
+ if (er) {
123
134
  return cb(er)
135
+ }
124
136
  bufPos += bytes
125
137
  if (bufPos < 512 && bytes) {
126
138
  return fs.read(
@@ -129,27 +141,33 @@ const replace = (opt, files, cb) => {
129
141
  )
130
142
  }
131
143
 
132
- if (position === 0 && headBuf[0] === 0x1f && headBuf[1] === 0x8b)
144
+ if (position === 0 && headBuf[0] === 0x1f && headBuf[1] === 0x8b) {
133
145
  return cb(new Error('cannot append to compressed archives'))
146
+ }
134
147
 
135
148
  // truncated header
136
- if (bufPos < 512)
149
+ if (bufPos < 512) {
137
150
  return cb(null, position)
151
+ }
138
152
 
139
153
  const h = new Header(headBuf)
140
- if (!h.cksumValid)
154
+ if (!h.cksumValid) {
141
155
  return cb(null, position)
156
+ }
142
157
 
143
158
  const entryBlockSize = 512 * Math.ceil(h.size / 512)
144
- if (position + entryBlockSize + 512 > size)
159
+ if (position + entryBlockSize + 512 > size) {
145
160
  return cb(null, position)
161
+ }
146
162
 
147
163
  position += entryBlockSize + 512
148
- if (position >= size)
164
+ if (position >= size) {
149
165
  return cb(null, position)
166
+ }
150
167
 
151
- if (opt.mtimeCache)
168
+ if (opt.mtimeCache) {
152
169
  opt.mtimeCache.set(h.path, h.mtime)
170
+ }
153
171
  bufPos = 0
154
172
  fs.read(fd, headBuf, 0, 512, position, onread)
155
173
  }
@@ -165,16 +183,19 @@ const replace = (opt, files, cb) => {
165
183
  return fs.open(opt.file, flag, onopen)
166
184
  }
167
185
 
168
- if (er)
186
+ if (er) {
169
187
  return reject(er)
188
+ }
170
189
 
171
190
  fs.fstat(fd, (er, st) => {
172
- if (er)
191
+ if (er) {
173
192
  return fs.close(fd, () => reject(er))
193
+ }
174
194
 
175
195
  getPos(fd, st.size, (er, position) => {
176
- if (er)
196
+ if (er) {
177
197
  return reject(er)
198
+ }
178
199
  const stream = new fsm.WriteStream(opt.file, {
179
200
  fd: fd,
180
201
  start: position,
@@ -196,13 +217,14 @@ const addFilesSync = (p, files) => {
196
217
  files.forEach(file => {
197
218
  if (file.charAt(0) === '@') {
198
219
  t({
199
- file: path.resolve(p.cwd, file.substr(1)),
220
+ file: path.resolve(p.cwd, file.slice(1)),
200
221
  sync: true,
201
222
  noResume: true,
202
223
  onentry: entry => p.add(entry),
203
224
  })
204
- } else
225
+ } else {
205
226
  p.add(file)
227
+ }
206
228
  })
207
229
  p.end()
208
230
  }
@@ -212,12 +234,13 @@ const addFilesAsync = (p, files) => {
212
234
  const file = files.shift()
213
235
  if (file.charAt(0) === '@') {
214
236
  return t({
215
- file: path.resolve(p.cwd, file.substr(1)),
237
+ file: path.resolve(p.cwd, file.slice(1)),
216
238
  noResume: true,
217
239
  onentry: entry => p.add(entry),
218
240
  }).then(_ => addFilesAsync(p, files))
219
- } else
241
+ } else {
220
242
  p.add(file)
243
+ }
221
244
  }
222
245
  p.end()
223
246
  }
@@ -16,7 +16,7 @@ module.exports = path => {
16
16
  // but strip the //?/C:/ off of //?/C:/path
17
17
  const root = path.charAt(0) === '/' && path.slice(0, 4) !== '//?/' ? '/'
18
18
  : parsed.root
19
- path = path.substr(root.length)
19
+ path = path.slice(root.length)
20
20
  r += root
21
21
  parsed = parse(path)
22
22
  }
@@ -66,21 +66,24 @@ const isWindows = platform === 'win32'
66
66
  // See: https://github.com/npm/node-tar/issues/183
67
67
  /* istanbul ignore next */
68
68
  const unlinkFile = (path, cb) => {
69
- if (!isWindows)
69
+ if (!isWindows) {
70
70
  return fs.unlink(path, cb)
71
+ }
71
72
 
72
73
  const name = path + '.DELETE.' + crypto.randomBytes(16).toString('hex')
73
74
  fs.rename(path, name, er => {
74
- if (er)
75
+ if (er) {
75
76
  return cb(er)
77
+ }
76
78
  fs.unlink(name, cb)
77
79
  })
78
80
  }
79
81
 
80
82
  /* istanbul ignore next */
81
83
  const unlinkFileSync = path => {
82
- if (!isWindows)
84
+ if (!isWindows) {
83
85
  return fs.unlinkSync(path)
86
+ }
84
87
 
85
88
  const name = path + '.DELETE.' + crypto.randomBytes(16).toString('hex')
86
89
  fs.renameSync(path, name)
@@ -109,20 +112,23 @@ const pruneCache = (cache, abs) => {
109
112
  abs = cacheKeyNormalize(abs)
110
113
  for (const path of cache.keys()) {
111
114
  const pnorm = cacheKeyNormalize(path)
112
- if (pnorm === abs || pnorm.indexOf(abs + '/') === 0)
115
+ if (pnorm === abs || pnorm.indexOf(abs + '/') === 0) {
113
116
  cache.delete(path)
117
+ }
114
118
  }
115
119
  }
116
120
 
117
121
  const dropCache = cache => {
118
- for (const key of cache.keys())
122
+ for (const key of cache.keys()) {
119
123
  cache.delete(key)
124
+ }
120
125
  }
121
126
 
122
127
  class Unpack extends Parser {
123
128
  constructor (opt) {
124
- if (!opt)
129
+ if (!opt) {
125
130
  opt = {}
131
+ }
126
132
 
127
133
  opt.ondone = _ => {
128
134
  this[ENDED] = true
@@ -147,8 +153,9 @@ class Unpack extends Parser {
147
153
 
148
154
  if (typeof opt.uid === 'number' || typeof opt.gid === 'number') {
149
155
  // need both or neither
150
- if (typeof opt.uid !== 'number' || typeof opt.gid !== 'number')
156
+ if (typeof opt.uid !== 'number' || typeof opt.gid !== 'number') {
151
157
  throw new TypeError('cannot set owner without number uid and gid')
158
+ }
152
159
  if (opt.preserveOwner) {
153
160
  throw new TypeError(
154
161
  'cannot preserve owner in archive and also set owner explicitly')
@@ -163,10 +170,11 @@ class Unpack extends Parser {
163
170
  }
164
171
 
165
172
  // default true for root
166
- if (opt.preserveOwner === undefined && typeof opt.uid !== 'number')
173
+ if (opt.preserveOwner === undefined && typeof opt.uid !== 'number') {
167
174
  this.preserveOwner = process.getuid && process.getuid() === 0
168
- else
175
+ } else {
169
176
  this.preserveOwner = !!opt.preserveOwner
177
+ }
170
178
 
171
179
  this.processUid = (this.preserveOwner || this.setOwner) && process.getuid ?
172
180
  process.getuid() : null
@@ -215,8 +223,9 @@ class Unpack extends Parser {
215
223
  // when extracting. Mark those errors as unrecoverable, because
216
224
  // the Unpack contract cannot be met.
217
225
  warn (code, msg, data = {}) {
218
- if (code === 'TAR_BAD_ARCHIVE' || code === 'TAR_ABORT')
226
+ if (code === 'TAR_BAD_ARCHIVE' || code === 'TAR_ABORT') {
219
227
  data.recoverable = false
228
+ }
220
229
  return super.warn(code, msg, data)
221
230
  }
222
231
 
@@ -225,23 +234,24 @@ class Unpack extends Parser {
225
234
  this.emit('prefinish')
226
235
  this.emit('finish')
227
236
  this.emit('end')
228
- this.emit('close')
229
237
  }
230
238
  }
231
239
 
232
240
  [CHECKPATH] (entry) {
233
241
  if (this.strip) {
234
242
  const parts = normPath(entry.path).split('/')
235
- if (parts.length < this.strip)
243
+ if (parts.length < this.strip) {
236
244
  return false
245
+ }
237
246
  entry.path = parts.slice(this.strip).join('/')
238
247
 
239
248
  if (entry.type === 'Link') {
240
249
  const linkparts = normPath(entry.linkpath).split('/')
241
- if (linkparts.length >= this.strip)
250
+ if (linkparts.length >= this.strip) {
242
251
  entry.linkpath = linkparts.slice(this.strip).join('/')
243
- else
252
+ } else {
244
253
  return false
254
+ }
245
255
  }
246
256
  }
247
257
 
@@ -267,10 +277,11 @@ class Unpack extends Parser {
267
277
  }
268
278
  }
269
279
 
270
- if (path.isAbsolute(entry.path))
280
+ if (path.isAbsolute(entry.path)) {
271
281
  entry.absolute = normPath(path.resolve(entry.path))
272
- else
282
+ } else {
273
283
  entry.absolute = normPath(path.resolve(this.cwd, entry.path))
284
+ }
274
285
 
275
286
  // if we somehow ended up with a path that escapes the cwd, and we are
276
287
  // not in preservePaths mode, then something is fishy! This should have
@@ -292,32 +303,36 @@ class Unpack extends Parser {
292
303
  // may not replace the cwd with a different kind of thing entirely.
293
304
  if (entry.absolute === this.cwd &&
294
305
  entry.type !== 'Directory' &&
295
- entry.type !== 'GNUDumpDir')
306
+ entry.type !== 'GNUDumpDir') {
296
307
  return false
308
+ }
297
309
 
298
310
  // only encode : chars that aren't drive letter indicators
299
311
  if (this.win32) {
300
312
  const { root: aRoot } = path.win32.parse(entry.absolute)
301
- entry.absolute = aRoot + wc.encode(entry.absolute.substr(aRoot.length))
313
+ entry.absolute = aRoot + wc.encode(entry.absolute.slice(aRoot.length))
302
314
  const { root: pRoot } = path.win32.parse(entry.path)
303
- entry.path = pRoot + wc.encode(entry.path.substr(pRoot.length))
315
+ entry.path = pRoot + wc.encode(entry.path.slice(pRoot.length))
304
316
  }
305
317
 
306
318
  return true
307
319
  }
308
320
 
309
321
  [ONENTRY] (entry) {
310
- if (!this[CHECKPATH](entry))
322
+ if (!this[CHECKPATH](entry)) {
311
323
  return entry.resume()
324
+ }
312
325
 
313
326
  assert.equal(typeof entry.absolute, 'string')
314
327
 
315
328
  switch (entry.type) {
316
329
  case 'Directory':
317
330
  case 'GNUDumpDir':
318
- if (entry.mode)
331
+ if (entry.mode) {
319
332
  entry.mode = entry.mode | 0o700
333
+ }
320
334
 
335
+ // eslint-disable-next-line no-fallthrough
321
336
  case 'File':
322
337
  case 'OldFile':
323
338
  case 'ContiguousFile':
@@ -337,10 +352,10 @@ class Unpack extends Parser {
337
352
  // Cwd has to exist, or else nothing works. That's serious.
338
353
  // Other errors are warnings, which raise the error in strict
339
354
  // mode, but otherwise continue on.
340
- if (er.name === 'CwdError')
355
+ if (er.name === 'CwdError') {
341
356
  this.emit('error', er)
342
- else {
343
- this.warn('TAR_ENTRY_ERROR', er, {entry})
357
+ } else {
358
+ this.warn('TAR_ENTRY_ERROR', er, { entry })
344
359
  this[UNPEND]()
345
360
  entry.resume()
346
361
  }
@@ -390,8 +405,9 @@ class Unpack extends Parser {
390
405
  autoClose: false,
391
406
  })
392
407
  stream.on('error', er => {
393
- if (stream.fd)
408
+ if (stream.fd) {
394
409
  fs.close(stream.fd, () => {})
410
+ }
395
411
 
396
412
  // flush all the data out so that we aren't left hanging
397
413
  // if the error wasn't actually fatal. otherwise the parse
@@ -405,8 +421,9 @@ class Unpack extends Parser {
405
421
  const done = er => {
406
422
  if (er) {
407
423
  /* istanbul ignore else - we should always have a fd by now */
408
- if (stream.fd)
424
+ if (stream.fd) {
409
425
  fs.close(stream.fd, () => {})
426
+ }
410
427
 
411
428
  this[ONERROR](er, entry)
412
429
  fullyDone()
@@ -415,10 +432,11 @@ class Unpack extends Parser {
415
432
 
416
433
  if (--actions === 0) {
417
434
  fs.close(stream.fd, er => {
418
- if (er)
435
+ if (er) {
419
436
  this[ONERROR](er, entry)
420
- else
437
+ } else {
421
438
  this[UNPEND]()
439
+ }
422
440
  fullyDone()
423
441
  })
424
442
  }
@@ -498,7 +516,7 @@ class Unpack extends Parser {
498
516
  [UNSUPPORTED] (entry) {
499
517
  entry.unsupported = true
500
518
  this.warn('TAR_ENTRY_UNSUPPORTED',
501
- `unsupported entry type: ${entry.type}`, {entry})
519
+ `unsupported entry type: ${entry.type}`, { entry })
502
520
  entry.resume()
503
521
  }
504
522
 
@@ -540,8 +558,9 @@ class Unpack extends Parser {
540
558
  [CHECKFS] (entry) {
541
559
  this[PEND]()
542
560
  const paths = [entry.path]
543
- if (entry.linkpath)
561
+ if (entry.linkpath) {
544
562
  paths.push(entry.linkpath)
563
+ }
545
564
  this.reservations.reserve(paths, done => this[CHECKFS2](entry, done))
546
565
  }
547
566
 
@@ -556,10 +575,11 @@ class Unpack extends Parser {
556
575
  // entry, it'll just fail to unpack, but a symlink to a directory, using an
557
576
  // 8.3 shortname or certain unicode attacks, can evade detection and lead
558
577
  // to arbitrary writes to anywhere on the system.
559
- if (entry.type === 'SymbolicLink')
578
+ if (entry.type === 'SymbolicLink') {
560
579
  dropCache(this.dirCache)
561
- else if (entry.type !== 'Directory')
580
+ } else if (entry.type !== 'Directory') {
562
581
  pruneCache(this.dirCache, entry.absolute)
582
+ }
563
583
  }
564
584
 
565
585
  [CHECKFS2] (entry, fullyDone) {
@@ -606,8 +626,9 @@ class Unpack extends Parser {
606
626
  done()
607
627
  return
608
628
  }
609
- if (lstatEr || this[ISREUSABLE](entry, st))
629
+ if (lstatEr || this[ISREUSABLE](entry, st)) {
610
630
  return this[MAKEFS](null, entry, done)
631
+ }
611
632
 
612
633
  if (st.isDirectory()) {
613
634
  if (entry.type === 'Directory') {
@@ -615,8 +636,9 @@ class Unpack extends Parser {
615
636
  entry.mode &&
616
637
  (st.mode & 0o7777) !== entry.mode
617
638
  const afterChmod = er => this[MAKEFS](er, entry, done)
618
- if (!needChmod)
639
+ if (!needChmod) {
619
640
  return afterChmod()
641
+ }
620
642
  return fs.chmod(entry.absolute, entry.mode, afterChmod)
621
643
  }
622
644
  // Not a dir entry, have to remove it.
@@ -634,18 +656,20 @@ class Unpack extends Parser {
634
656
 
635
657
  // not a dir, and not reusable
636
658
  // don't remove if the cwd, we want that error
637
- if (entry.absolute === this.cwd)
659
+ if (entry.absolute === this.cwd) {
638
660
  return this[MAKEFS](null, entry, done)
661
+ }
639
662
 
640
663
  unlinkFile(entry.absolute, er =>
641
664
  this[MAKEFS](er, entry, done))
642
665
  })
643
666
  }
644
667
 
645
- if (this[CHECKED_CWD])
668
+ if (this[CHECKED_CWD]) {
646
669
  start()
647
- else
670
+ } else {
648
671
  checkCwd()
672
+ }
649
673
  }
650
674
 
651
675
  [MAKEFS] (er, entry, done) {
@@ -676,9 +700,9 @@ class Unpack extends Parser {
676
700
  [LINK] (entry, linkpath, link, done) {
677
701
  // XXX: get the type ('symlink' or 'junction') for windows
678
702
  fs[link](linkpath, entry.absolute, er => {
679
- if (er)
703
+ if (er) {
680
704
  this[ONERROR](er, entry)
681
- else {
705
+ } else {
682
706
  this[UNPEND]()
683
707
  entry.resume()
684
708
  }
@@ -704,8 +728,9 @@ class UnpackSync extends Unpack {
704
728
 
705
729
  if (!this[CHECKED_CWD]) {
706
730
  const er = this[MKDIR](this.cwd, this.dmode)
707
- if (er)
731
+ if (er) {
708
732
  return this[ONERROR](er, entry)
733
+ }
709
734
  this[CHECKED_CWD] = true
710
735
  }
711
736
 
@@ -715,17 +740,20 @@ class UnpackSync extends Unpack {
715
740
  const parent = normPath(path.dirname(entry.absolute))
716
741
  if (parent !== this.cwd) {
717
742
  const mkParent = this[MKDIR](parent, this.dmode)
718
- if (mkParent)
743
+ if (mkParent) {
719
744
  return this[ONERROR](mkParent, entry)
745
+ }
720
746
  }
721
747
  }
722
748
 
723
749
  const [lstatEr, st] = callSync(() => fs.lstatSync(entry.absolute))
724
- if (st && (this.keep || this.newer && st.mtime > entry.mtime))
750
+ if (st && (this.keep || this.newer && st.mtime > entry.mtime)) {
725
751
  return this[SKIP](entry)
752
+ }
726
753
 
727
- if (lstatEr || this[ISREUSABLE](entry, st))
754
+ if (lstatEr || this[ISREUSABLE](entry, st)) {
728
755
  return this[MAKEFS](null, entry)
756
+ }
729
757
 
730
758
  if (st.isDirectory()) {
731
759
  if (entry.type === 'Directory') {
@@ -759,8 +787,9 @@ class UnpackSync extends Unpack {
759
787
  } catch (e) {
760
788
  closeError = e
761
789
  }
762
- if (er || closeError)
790
+ if (er || closeError) {
763
791
  this[ONERROR](er || closeError, entry)
792
+ }
764
793
  done()
765
794
  }
766
795
 
@@ -9,14 +9,17 @@ const r = require('./replace.js')
9
9
  module.exports = (opt_, files, cb) => {
10
10
  const opt = hlo(opt_)
11
11
 
12
- if (!opt.file)
12
+ if (!opt.file) {
13
13
  throw new TypeError('file is required')
14
+ }
14
15
 
15
- if (opt.gzip)
16
+ if (opt.gzip) {
16
17
  throw new TypeError('cannot append to compressed archives')
18
+ }
17
19
 
18
- if (!files || !Array.isArray(files) || !files.length)
20
+ if (!files || !Array.isArray(files) || !files.length) {
19
21
  throw new TypeError('no files or directories specified')
22
+ }
20
23
 
21
24
  files = Array.from(files)
22
25
 
@@ -27,8 +30,9 @@ module.exports = (opt_, files, cb) => {
27
30
  const mtimeFilter = opt => {
28
31
  const filter = opt.filter
29
32
 
30
- if (!opt.mtimeCache)
33
+ if (!opt.mtimeCache) {
31
34
  opt.mtimeCache = new Map()
35
+ }
32
36
 
33
37
  opt.filter = filter ? (path, stat) =>
34
38
  filter(path, stat) && !(opt.mtimeCache.get(path) > stat.mtime)
@@ -1,10 +1,12 @@
1
1
  'use strict'
2
2
  module.exports = Base => class extends Base {
3
3
  warn (code, message, data = {}) {
4
- if (this.file)
4
+ if (this.file) {
5
5
  data.file = this.file
6
- if (this.cwd)
6
+ }
7
+ if (this.cwd) {
7
8
  data.cwd = this.cwd
9
+ }
8
10
  data.code = message instanceof Error && message.code || code
9
11
  data.tarCode = code
10
12
  if (!this.strict && data.recoverable !== false) {
@@ -13,9 +15,10 @@ module.exports = Base => class extends Base {
13
15
  message = message.message
14
16
  }
15
17
  this.emit('warn', data.tarCode, message, data)
16
- } else if (message instanceof Error)
18
+ } else if (message instanceof Error) {
17
19
  this.emit('error', Object.assign(message, data))
18
- else
20
+ } else {
19
21
  this.emit('error', Object.assign(new Error(`${code}: ${message}`), data))
22
+ }
20
23
  }
21
24
  }