Cakefile 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. exec = require('child_process').exec
  2. fs = require 'fs'
  3. sysPath = require 'path'
  4. task 'compile:coffee', ->
  5. unless fs.existsSync './scripts/js'
  6. fs.mkdirSync './scripts/js'
  7. exec 'node ./node_modules/coffee-script/bin/coffee -bco ./scripts/js ./scripts/coffee',
  8. (error) ->
  9. if fs.existsSync '-p'
  10. fs.rmdirSync '-p'
  11. if error?
  12. console.log 'Compile failed: ' + error
  13. return
  14. task 'build', ->
  15. invoke 'compile:coffee'
  16. # This is in place until we replace the test suite runner with popo
  17. task 'test', ->
  18. runTestsIn 'scripts/coffee/test', '_prepare.coffee'
  19. runInCoffee = (path, cb) ->
  20. exec 'node ./node_modules/coffee-script/bin/coffee ' + path, cb
  21. runTestsIn = (shortPath, except) ->
  22. fullPath = sysPath.resolve shortPath
  23. fs.readdir fullPath, (err, files) ->
  24. if err then throw Error err
  25. for file in files
  26. return if file is except
  27. fullFilePath = sysPath.resolve(fullPath, file)
  28. shortFilePath = shortPath + '/' + file
  29. if sysPath.extname(file) is '.coffee'
  30. runAsTest shortFilePath, fullFilePath
  31. else if fs.statSync(fullFilePath).isDirectory()
  32. runTestsIn shortFilePath
  33. return
  34. didBeep = no
  35. runAsTest = (shortPath, fullPath) ->
  36. runInCoffee fullPath, (error, stdout, stderr) ->
  37. output = 'Running ' + shortPath + '\n'
  38. if stderr
  39. unless didBeep
  40. `console.log("\007")`
  41. didBeep = yes
  42. output += 'Error\n' + stdout + stderr + '\n'
  43. else if stdout
  44. output += '\n' + stdout
  45. console.log output