887d18ee36ed3fdaf190bd80378bbced3943c5f8fc209c31c5733adcd05742fae52479d0cdc13801a5428eed08d5ad5b9223652eaadb13b704ba010fd26b88 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. "use strict";
  2. // tar -u
  3. Object.defineProperty(exports, "__esModule", { value: true });
  4. exports.update = void 0;
  5. const make_command_js_1 = require("./make-command.js");
  6. const replace_js_1 = require("./replace.js");
  7. // just call tar.r with the filter and mtimeCache
  8. exports.update = (0, make_command_js_1.makeCommand)(replace_js_1.replace.syncFile, replace_js_1.replace.asyncFile, replace_js_1.replace.syncNoFile, replace_js_1.replace.asyncNoFile, (opt, entries = []) => {
  9. replace_js_1.replace.validate?.(opt, entries);
  10. mtimeFilter(opt);
  11. });
  12. const mtimeFilter = (opt) => {
  13. const filter = opt.filter;
  14. if (!opt.mtimeCache) {
  15. opt.mtimeCache = new Map();
  16. }
  17. opt.filter =
  18. filter ?
  19. (path, stat) => filter(path, stat) &&
  20. !(
  21. /* c8 ignore start */
  22. ((opt.mtimeCache?.get(path) ?? stat.mtime ?? 0) >
  23. (stat.mtime ?? 0))
  24. /* c8 ignore stop */
  25. )
  26. : (path, stat) => !(
  27. /* c8 ignore start */
  28. ((opt.mtimeCache?.get(path) ?? stat.mtime ?? 0) >
  29. (stat.mtime ?? 0))
  30. /* c8 ignore stop */
  31. );
  32. };
  33. //# sourceMappingURL=update.js.map