Re:CoffeeScript -- You Are Totally Gonna Hate It
by gfodor on Saturday July 17, 2010 @01:36PM
(#1524226)
This right here is why CoffeeScript is so awesome. Jeremy is awesome, and continues to make it so.
Re:CoffeeScript -- You Are Totally Gonna Hate It
by endtime on Sunday July 18, 2010 @01:15AM
(#1525276)
Thanks Jeremy. I don't particularly want to use child_process.exec if there's a better/more direct way to compile, which it seems like there must be. I think it would be really helpful to have a dead simple Cakefile example for compiling a single CS file into a single JS file. It's not clear to me what the standard way to do that is, even with your new example.
Re:CoffeeScript -- You Are Totally Gonna Hate It
by jashkenas on Sunday July 18, 2010 @07:46AM
(#1525608)
I'm sorry -- if you'd like to use the compiler directly, here's an example:
fs: require 'fs'
fs.readFile source, (err, code) ->
try
js: CoffeeScript.compile(code.toString(), {source})
fs.writeFile 'out.js', js
catch err
console.log err
Here's the source of the "CoffeeScript.compile" method:http://jashkenas.github.com/coffee-script/documentation/docs...
http://jashkenas.github.com/coffee-script/#heredocs
And extended the section on "cake" a little bit with a better example that demonstrates passing in a command-line option. It sounds like your problem is different though -- here's the Node.js docs for child_process.exec:
http://nodejs.org/api.html#child_process-exec-95
You can use the "stderr" argument in the callback function to print the child's error output to the console. Running this bit of CoffeeScript, for example, will print out "to stderr":