4 ms·
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
by endtime 16y ago
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.
- revorad 16y agoWhat library are you writing?
- endtime 16y agoIt's for work - won't be widely distributed, I'm afraid.
- jashkenas 16y agoThanks 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 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 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
- gfodor 16y agoThis right here is why CoffeeScript is so awesome. Jeremy is awesome, and continues to make it so.
- endtime 16y agoThanks 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.
- jashkenas 16y agoI'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/coffee-script.html#section-5 http://jashkenas.github.com/coffee-script/documentation/docs...
- endtime 16y agoOh, cool, thanks. I also just learned that {source} is short for {source: source}. That's something else missing from the docs, I believe.