fs = require 'fs' {exec,spawn} = require 'child_process' util = require 'util' sources = [ 'markdown.coffee' 'view.coffee' 'unit.coffee' 'character.coffee' 'room.coffee' 'localize.coffee' 'salet.coffee' ] sourcestring = "" for source in sources sourcestring += 'src/'+source+' ' task 'watch', 'Watch source files and build changes', -> watch = spawn "coffee", ['-c', '-w', '--no-header', '-j', 'lib/index.js', sourcestring] watch.stdout.on 'data', (data) -> console.log data.toString().trim() task 'build', 'Compile all CoffeeScript files', -> # prepare lib directory if not fs.existsSync 'lib' fs.mkdirSync 'lib' # run coffee-script compile exec "coffee -c --no-header -j lib/index.js #{sourcestring}", (err, stdout, stderr) -> if err util.log err process.exit 1 # abort npm packaging util.log "Compiled CoffeeScript."