javascript - Coffeescript 编译器和观察器

标签 javascript build coffeescript watch

我对 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/

相关文章:

javascript - Asp.net 使用 JavaScript

android - 运行通过Artifactory分发的库的build.gradle

c# - Visual Studio 生成操作的当前类型 - Microsoft.VisualStudio.Shell.Interop

javascript - 在jquery中,如何获取使用复选框选择的表的特定行的值?

javascript - Xpathresult 在 IE11 中未定义

javascript - Angular 模型在资源 promise 内为空

java - 团结 : CommandInvokationFailure: Failed to recompile android resource files

javascript - 引用错误: Can't find variable: goToByScroll using CoffeScript

javascript - 循环遍历不同的按钮文本.onClick

javascript - 如何跟踪在网站上花费的时间