Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Coffe Blender for your coffee scripts
- # It watches coffee for changes and compiles
- # ======
- # coffee --no-wrap -c watcher.coffee # Compile it, onetime
- #
- # Now you can eiher supply the files from the command line:
- # node watcher.js my_file.coffee
- # or pass them through stdin:
- # find . | grep coffee$| node watcher.js -
- # git ls-files | grep coffee$| node watcher.js -
- puts: require('sys').puts
- exec: require('child_process').exec
- watch: require('fs').watchFile
- blend: (filename) ->
- exec "coffee --no-wrap -c $filename", (err, stderr, stdout) ->
- puts(if err then "! $stdout" else "= Blended $filename")
- register: (file) ->
- puts "+ Registering $file"
- blend file
- watch file, (curr, prev) ->
- blend file
- args: process.argv[2...process.argv.length]
- if args[0] == '-'
- files: []
- stdin: process.openStdin()
- stdin.addListener 'data', (chunk) ->
- data: chunk.toString('ascii')
- files.push(file) for file in data.split('\n') when file isnt ''
- stdin.addListener 'end', ->
- register file for file in files
- else
- files: args
- register file for file in files
Add Comment
Please, Sign In to add comment