1bf8af45676a65a0a78eaaa51cab1a2816a4121191941b85f705e17fa0b84e25d94ce6cbcc6f356e295f9aa11c7ebba94082ff677f54e301b4ee0b2810709e 1.6 KB

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