我对 CoffeeScript 非常陌生,我正在开发环境中工作,我想询问实验用户他们的用途:
- 自动 Coffescript 编译器
- 自动 Coffescript 观察器
我遇到了蛋糕
、Grunt
。
我只是之前编译和观看我的 coffescript 代码的最佳实践之一。
最佳答案
蛋糕是您正在寻找的选择,它很轻,而且很有效。
这里是编译和观看的主要脚本。
fs = require 'fs'
{exec} = require 'child_process'
appFiles = [
# omit src/ and .coffee to make the below lines a little shorter
'content/scripts/statusbar'
'content/scripts/command/quickMacro'
'content/scripts/command/selectionTools/general'
]
task 'build', 'Build single application file from source files', ->
appContents = new Array remaining = appFiles.length
for file, index in appFiles then do (file, index) ->
fs.readFile "src/#{file}.coffee", 'utf8', (err, fileContents) ->
throw err if err
appContents[index] = fileContents
process() if --remaining is 0
process = ->
fs.writeFile 'lib/app.coffee', appContents.join('\n\n'), 'utf8', (err) ->
throw err if err
exec 'coffee --compile lib/app.coffee', (err, stdout, stderr) ->
throw err if err
console.log stdout + stderr
fs.unlink 'lib/app.coffee', (err) ->
throw err if err
console.log 'Done.'
更多信息请参见 here
关于javascript - Coffeescript 编译器和观察器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28507602/