Guest User

Untitled

a guest
May 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. # Coffe Blender for your coffee scripts
  2. # It watches coffee for changes and compiles
  3. # ======
  4. # coffee --no-wrap -c watcher.coffee # Compile it, onetime
  5. #
  6. # Now you can eiher supply the files from the command line:
  7. # node watcher.js my_file.coffee
  8. # or pass them through stdin:
  9. # find . | grep coffee$| node watcher.js -
  10. # git ls-files | grep coffee$| node watcher.js -
  11.  
  12. puts: require('sys').puts
  13. exec: require('child_process').exec
  14. watch: require('fs').watchFile
  15.  
  16. blend: (filename) ->
  17. exec "coffee --no-wrap -c $filename", (err, stderr, stdout) ->
  18. puts(if err then "! $stdout" else "= Blended $filename")
  19.  
  20. register: (file) ->
  21. puts "+ Registering $file"
  22. blend file
  23. watch file, (curr, prev) ->
  24. blend file
  25.  
  26. args: process.argv[2...process.argv.length]
  27.  
  28. if args[0] == '-'
  29. files: []
  30. stdin: process.openStdin()
  31. stdin.addListener 'data', (chunk) ->
  32. data: chunk.toString('ascii')
  33. files.push(file) for file in data.split('\n') when file isnt ''
  34.  
  35. stdin.addListener 'end', ->
  36. register file for file in files
  37. else
  38. files: args
  39. register file for file in files
Add Comment
Please, Sign In to add comment