【问题标题】:How do you compile CoffeeScript in a Jakefile?你如何在 Jakefile 中编译 CoffeeScript?
【发布时间】:2011-09-26 18:12:14
【问题描述】:

我想创建一个 Jakefile 来编译一些 CoffeeScripts 以安装 NodeJS 应用程序。

你是怎么做到的?

我尝试过: https://gist.github.com/1241827

但这是一个弱的方法,绝对不是优雅的。

有什么提示吗?

【问题讨论】:

    标签: javascript node.js coffeescript jake


    【解决方案1】:

    我用过的大概sn-p:

    var fs = require('fs')
    var coffee = require('coffee-script')
    
    // If you'd like to see compiled code..
    // console.log(coffee.compile(fs.readFileSync('coffee.coffee')))
    
    // ..otherwise
    fs.writeFileSync('output.js', coffee.compile(fs.readFileSync('input.coffee')))
    

    ..当然,假设您安装了 coffee-script 节点模块。

    翻译自我的Cakefile

    【讨论】:

    • 我已经看过coffee的.compile()方法,但我想知道是否有不使用FS的方法。无论如何,谢谢,我会用这个sn-p!
    猜你喜欢
    • 2012-08-24
    • 2011-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-27
    相关资源
    最近更新 更多