Cakefile 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. {spawn, exec} = require "child_process"
  2. watch = require "nodewatch"
  3. task "spec", "Runs the Jasmine specs.", ->
  4. header()
  5. jasmine = spawn "node", ["node_modules/jasmine-node/lib/jasmine-node/cli.js", "--coffee", "-i", "src", "spec"]
  6. jasmine.stdout.on "data", (data) ->
  7. process.stdout.write data
  8. jasmine.stderr.on "data", (data) ->
  9. process.stderr.write data
  10. jasmine.stdin.end()
  11. task "watch", "Watches for file changes, recompiling CoffeeScript and running the Jasmine specs.", ->
  12. console.log "Watching Shellwords for changes...\n"
  13. invoke "spec"
  14. watch.add("src").add("spec").onChange (file, prev, cur) ->
  15. exec "coffee -co lib src", (error, stdout, stderr) ->
  16. throw error if error
  17. invoke "spec"
  18. header = ->
  19. divider = "------------"
  20. console.log divider, dateString(), divider
  21. dateString = ->
  22. d = new Date
  23. h = d.getHours()
  24. m = d.getMinutes()
  25. s = d.getSeconds()
  26. meridiem = if h >= 12 then "PM" else "AM"
  27. h -= 12 if h > 12
  28. h = 12 if h is 0
  29. m = "0" + m if m < 10
  30. s = "0" + s if s < 10
  31. "#{d.toLocaleDateString()} #{h}:#{m}:#{s} #{meridiem}"