Re:CoffeeScript -- You Are Totally Gonna Hate It
by endtime on Saturday July 17, 2010 @09:51AM
(#1523766)
I've been using CoffeeScript the last few weeks (writing a library using Raphael) and I'm really enjoying it. My one complaint is that the documentation has a few holes - in particular, it took me a little while to work out how to do block comments (### on either end), and more importantly, there's nowhere near enough documentation on cake. Right now my Cakefile uses child_process.exec, which is kind of lame and also doesn't show compilation errors.
[ Parent
| on HN ]
Re:CoffeeScript -- You Are Totally Gonna Hate It
by jashkenas on Saturday July 17, 2010 @10:40AM
(#1523843)
Thanks for the documentation tips -- it's always helpful to hear what's missing from the perspective of a pair of fresh eyes. I've updated the documentation with an example of block comments:
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":
{exec}: require 'child_process'
exec 'echo "to stderr" >&2', (err, stdout, stderr) ->
print stderr
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...
Re:CoffeeScript -- You Are Totally Gonna Hate It
by endtime on Monday July 19, 2010 @02:20AM
(#1527784)
Oh, cool, thanks. I also just learned that {source} is short for {source: source}. That's something else missing from the docs, I believe.