Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you compile CoffeeScript in a Jakefile?

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?

like image 857
odino Avatar asked Sep 26 '11 08:09

odino


1 Answers

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.

like image 50
Jacob Oscarson Avatar answered Oct 26 '22 16:10

Jacob Oscarson