Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

CoffeeScript compiler API

CoffeeScript compiler API


I am working in Coffeescript (writing a Cakefile). I would like to compile some other CoffeeScript files, à la

coffee -o lib -c src

I could launch the above command in a child process, but this approach has cross-platform issues and makes error handling difficult. I'd much rather use an API.

I'd be happy to use the exact functions from, but I can't work out how.

Addendum: I see require('coffee-script').compile, which compiles a string to another string. That would still leave me to do the grunt work of looping over files and subfolders and writing the output.

Problem courtesy of: Colonel Panic


The API you're looking for is in It exports a compile function that does what it says on the tin.

To use's run function directly you'd have to first overwrite process.argv with the options you would have passed on the command line.

Solution courtesy of: Jordan Running


View additional discussion.

This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

CoffeeScript compiler API


Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription