touch.js 757 B

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