25f61b76f18c59a66d109c0ce26edede7fa7225b3c6c782f4568524ab6eeeb7f516c57873f54080c1430de9edeed68c18b8c5b05ceb7e95516232e6459afd4 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. "use strict";
  2. // turn tar(1) style args like `C` into the more verbose things like `cwd`
  3. Object.defineProperty(exports, "__esModule", { value: true });
  4. exports.dealias = exports.isNoFile = exports.isFile = exports.isAsync = exports.isSync = exports.isAsyncNoFile = exports.isSyncNoFile = exports.isAsyncFile = exports.isSyncFile = void 0;
  5. const argmap = new Map([
  6. ['C', 'cwd'],
  7. ['f', 'file'],
  8. ['z', 'gzip'],
  9. ['P', 'preservePaths'],
  10. ['U', 'unlink'],
  11. ['strip-components', 'strip'],
  12. ['stripComponents', 'strip'],
  13. ['keep-newer', 'newer'],
  14. ['keepNewer', 'newer'],
  15. ['keep-newer-files', 'newer'],
  16. ['keepNewerFiles', 'newer'],
  17. ['k', 'keep'],
  18. ['keep-existing', 'keep'],
  19. ['keepExisting', 'keep'],
  20. ['m', 'noMtime'],
  21. ['no-mtime', 'noMtime'],
  22. ['p', 'preserveOwner'],
  23. ['L', 'follow'],
  24. ['h', 'follow'],
  25. ['onentry', 'onReadEntry'],
  26. ]);
  27. const isSyncFile = (o) => !!o.sync && !!o.file;
  28. exports.isSyncFile = isSyncFile;
  29. const isAsyncFile = (o) => !o.sync && !!o.file;
  30. exports.isAsyncFile = isAsyncFile;
  31. const isSyncNoFile = (o) => !!o.sync && !o.file;
  32. exports.isSyncNoFile = isSyncNoFile;
  33. const isAsyncNoFile = (o) => !o.sync && !o.file;
  34. exports.isAsyncNoFile = isAsyncNoFile;
  35. const isSync = (o) => !!o.sync;
  36. exports.isSync = isSync;
  37. const isAsync = (o) => !o.sync;
  38. exports.isAsync = isAsync;
  39. const isFile = (o) => !!o.file;
  40. exports.isFile = isFile;
  41. const isNoFile = (o) => !o.file;
  42. exports.isNoFile = isNoFile;
  43. const dealiasKey = (k) => {
  44. const d = argmap.get(k);
  45. if (d)
  46. return d;
  47. return k;
  48. };
  49. const dealias = (opt = {}) => {
  50. if (!opt)
  51. return {};
  52. const result = {};
  53. for (const [key, v] of Object.entries(opt)) {
  54. // TS doesn't know that aliases are going to always be the same type
  55. const k = dealiasKey(key);
  56. result[k] = v;
  57. }
  58. // affordance for deprecated noChmod -> chmod
  59. if (result.chmod === undefined && result.noChmod === false) {
  60. result.chmod = true;
  61. }
  62. delete result.noChmod;
  63. return result;
  64. };
  65. exports.dealias = dealias;
  66. //# sourceMappingURL=options.js.map