Cake

http://jashkenas.github.com/coffee-script/#cake

RubyのRakeのようなもの

自動コンパイル

coffeeディレクトリの中を監視して、変更があったらコンパイルしてjsディレクトリに保存するCakefile

http://d.hatena.ne.jp/podhmo/20110108/1294500491 より)

aptでlibnotify-binをインストールしておくとポップアップで通知してくれる。

Cakefile

sys = require 'sys'

fs = require 'fs'

exec = require('child_process').exec

spawn = require('child_process').spawn

task 'watch', 'watches and compiles coffee file', ->

sys.puts "Spawning coffee watcher..."

coffee = spawn 'coffee', ['-cwl', '-o', "js", "coffee"]

[coffee].forEach (child) ->

child.stdout.on 'data', (data) ->

sys.print data

exec "notify-send Cakefile \"#{data}\""

child.stderr.on 'data', (data) ->

sys.print data

exec "notify-send \"Cakefile(fail)\" \#{data}\""

実行

$ cake watch

ちなみに以下のcoffeeコマンドで同じことができる。

$ coffee -o js -w coffee