touch.js 777 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env node
  2. var touch = require("../touch")
  3. , fs = require("fs")
  4. , path = require("path")
  5. , nopt = require("nopt")
  6. , types = { atime: Boolean
  7. , mtime: Boolean
  8. , time: Date
  9. , ref: path
  10. , nocreate: Boolean
  11. , force: Boolean }
  12. , shorthands = { a: "--atime"
  13. , m: "--mtime"
  14. , r: "--ref"
  15. , t: "--time"
  16. , c: "--nocreate"
  17. , f: "--force" }
  18. var options = nopt(types, shorthands)
  19. var files = options.argv.remain
  20. delete options.argv
  21. files.forEach(function (file) {
  22. touch(file, options, function (er) {
  23. if (er) {
  24. console.error("bad touch!")
  25. throw er
  26. }
  27. console.error(file, fs.statSync(file))
  28. })
  29. })