source: trip-planner-front/node_modules/tar/lib/update.js@ b738035

Last change on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 842 bytes
Line 
1'use strict'
2
3// tar -u
4
5const hlo = require('./high-level-opt.js')
6const r = require('./replace.js')
7// just call tar.r with the filter and mtimeCache
8
9module.exports = (opt_, files, cb) => {
10 const opt = hlo(opt_)
11
12 if (!opt.file)
13 throw new TypeError('file is required')
14
15 if (opt.gzip)
16 throw new TypeError('cannot append to compressed archives')
17
18 if (!files || !Array.isArray(files) || !files.length)
19 throw new TypeError('no files or directories specified')
20
21 files = Array.from(files)
22
23 mtimeFilter(opt)
24 return r(opt, files, cb)
25}
26
27const mtimeFilter = opt => {
28 const filter = opt.filter
29
30 if (!opt.mtimeCache)
31 opt.mtimeCache = new Map()
32
33 opt.filter = filter ? (path, stat) =>
34 filter(path, stat) && !(opt.mtimeCache.get(path) > stat.mtime)
35 : (path, stat) => !(opt.mtimeCache.get(path) > stat.mtime)
36}
Note: See TracBrowser for help on using the repository browser.