high-level-opt.js 760 B

1234567891011121314151617181920212223242526272829
  1. 'use strict'
  2. // turn tar(1) style args like `C` into the more verbose things like `cwd`
  3. const argmap = new Map([
  4. ['C', 'cwd'],
  5. ['f', 'file'],
  6. ['z', 'gzip'],
  7. ['P', 'preservePaths'],
  8. ['U', 'unlink'],
  9. ['strip-components', 'strip'],
  10. ['stripComponents', 'strip'],
  11. ['keep-newer', 'newer'],
  12. ['keepNewer', 'newer'],
  13. ['keep-newer-files', 'newer'],
  14. ['keepNewerFiles', 'newer'],
  15. ['k', 'keep'],
  16. ['keep-existing', 'keep'],
  17. ['keepExisting', 'keep'],
  18. ['m', 'noMtime'],
  19. ['no-mtime', 'noMtime'],
  20. ['p', 'preserveOwner'],
  21. ['L', 'follow'],
  22. ['h', 'follow'],
  23. ])
  24. module.exports = opt => opt ? Object.keys(opt).map(k => [
  25. argmap.has(k) ? argmap.get(k) : k, opt[k],
  26. ]).reduce((set, kv) => (set[kv[0]] = kv[1], set), Object.create(null)) : {}