6

I would like to create a Jakefile which compiles some CoffeeScripts to install a NodeJS application.

How do you do that?

I tried with: https://gist.github.com/1241827

but it's a weak approach, definitely not classy.

Any hints?

odino
  • 1,069
  • 11
  • 27

1 Answers1

3

Approx snippet I have used:

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')))

..assumes you have the coffee-script node module installed, of course.

Translated from this Cakefile of mine.

Jacob Oscarson
  • 6,363
  • 1
  • 36
  • 46
  • I already had a look at the .compile() method of coffee, but I was wondering if there was a way not to use the FS. Anyway, thanks, I will use this snippet! – odino Sep 26 '11 at 10:24