Created
July 7, 2011 21:25
-
-
Save michaelficarra/1070574 to your computer and use it in GitHub Desktop.
change when module/require are added to sandbox in REPL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/coffee-script.coffee b/src/coffee-script.coffee | |
| --- a/src/coffee-script.coffee | |
| +++ b/src/coffee-script.coffee | |
| @@ -88,8 +88,7 @@ exports.eval = (code, options = {}) -> | |
| sandbox[k] = v for own k, v of options.sandbox | |
| sandbox.__filename = options.filename || 'eval' | |
| sandbox.__dirname = path.dirname sandbox.__filename | |
| - # define module/require only if they chose not to specify their own | |
| - unless sandbox.module or sandbox.require | |
| + unless options.sandbox? | |
| Module = require 'module' | |
| sandbox.module = _module = new Module(options.modulename || 'eval') | |
| sandbox.require = _require = (path) -> Module._load path, _module |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This would unfortunately force us to duplicate the module-/require-generating code (8 lines!) in the REPL function. Though it would be a slightly better behaviour, I don't think it's worth it.