Sage/streamlinejs — pull request #100 by aseemk (2012-05-29 12:41:44+00:00)
Title: CoffeeScript improvements and more

*[Repeat of #98 to be off the tip of dvlp instead of master now.]*

Great news -- I've improved the code around loading/compiling/running files, both JS and CoffeeScript. Pull request attached.

My initial motivations were to remove redundant CoffeeScript file reading and to register `.coffee` and `._coffee` handlers only if CoffeeScript was already or explicitly being used, but in the process, I found a bunch of other fixes to be made.

The individual commits are documented and descriptive, so take a look, but in a nutshell, here are the additional fixes and improvements:

- Now supports package.json "main" values being directories too, like Node. In fact, achieved this by using Node's own helper function.

- Shebangs are removed for require()'d ._js content too now, again like Node.

- You can now run .js and ._js files with the _coffee binary. In other words, _coffee is a superset of _node, just like _node is a superset of node.

- Fixed #84! Found a way to (manually) load CoffeeScript relative to the caller's directory, so doing that now, both for running/compiling via _coffee and for loading via require().

Also in the process, I was able to simplify and clean the code (underscored.js in particular) quite a bit.

Hope you like these changes! =)