codekingpro/portable-devtools
114k
1// tar -u
2import { makeCommand } from './make-command.js';
3import { replace as r } from './replace.js';
4// just call tar.r with the filter and mtimeCache
5export const update = makeCommand(r.syncFile, r.asyncFile, r.syncNoFile, r.asyncNoFile, (opt, entries = []) => {
6 r.validate?.(opt, entries);
7 mtimeFilter(opt);
8});
9const mtimeFilter = (opt) => {
10 const filter = opt.filter;
11 if (!opt.mtimeCache) {
12 opt.mtimeCache = new Map();
13 }
14 opt.filter =
15 filter ?
16 (path, stat) => filter(path, stat) &&
17 !(
18 /* c8 ignore start */
19 ((opt.mtimeCache?.get(path) ?? stat.mtime ?? 0) >
20 (stat.mtime ?? 0))
21 /* c8 ignore stop */
22 )
23 : (path, stat) => !(
24 /* c8 ignore start */
25 ((opt.mtimeCache?.get(path) ?? stat.mtime ?? 0) >
26 (stat.mtime ?? 0))
27 /* c8 ignore stop */
28 );
29};
30//# sourceMappingURL=update.js.map