目前,我使用它来将其编译为文件:
task 'CurrentVillage', 'Build Current Vilage', ->
remaining = appFiles.length
appContents = new Array remaining
for file, index in appFiles then do (file, index) ->
fs.readFile "media/coffee/#{file}.coffee", 'utf8', (err, fileContents) ->
throw err if err
appContents[index] = fileContents
process() if --remaining is 0
process = ->
fs.writeFile 'media/coffee/frontend/VillageCanvas.coffee', appContents.join('\n\n'), 'utf8', (err) ->
throw err if err
我没有将其直接编译为javascript:S
最佳答案
您需要在Cakefile
中定义任务,然后调用该Cakefile。将cake build
放在同一目录后,从您的coffeescript文件所在的目录在终端中运行Cakefile
。这是一个Cakefile的简单模板。它已经具有如下所述的构建功能:http://twilson63.github.com/cakefile-template/
build = (watch, callback) ->
if typeof watch is 'function'
callback = watch
watch = false
options = ['-c', '-b', '-o', 'lib', 'src']
options.unshift '-w' if watch
launch 'coffee', options, callback