felixge/node-sandboxed-module — pull request #8 by AidenMontgomery (2012-03-01 04:00:33+00:00)
Title: CoffeeScript support added

I think that I have managed to add CoffeeScript support. This is my first attempt at contributing to a project on GitHub and my first attempt at altering a Node module, so I have no idea if what I have done is correct.

This should close the issue raised here https://github.com/felixge/node-sandboxed-module/issues/6

In the compile step source code was being read directly from the file system then concatenated into a JavaScript string. This caused problems when the source was used.

I have added a check to see if the source file ends in .coffee and if it does it will be compiled into JavaScript before being used in the concatenation.

This required the coffee-script module to be loaded into sandboxed_module.js so I have added a require('coffee-script') to this file and added coffee-script as an optional dependency in the package.json file.

I also added a very simple test that has sandboxed load a coffee script file, but doesn't do any injection, as it was the wrapping of the file contents that was the problem.

I have not updated any version numbers.