1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

don't copy arguments or caller from require

causes an error in io.js where strict-mode is set on internal modules

Fixes: https://github.com/jashkenas/coffeescript/issues/3810
This commit is contained in:
Rod Vagg 2015-06-22 22:36:29 +10:00
parent 1f197fcc1b
commit 75ae45e2bb
2 changed files with 3 additions and 2 deletions

View file

@ -175,7 +175,7 @@
ref3 = Object.getOwnPropertyNames(require);
for (i = 0, len = ref3.length; i < len; i++) {
r = ref3[i];
if (r !== 'paths') {
if (r !== 'paths' && r !== 'arguments' && r !== 'caller') {
_require[r] = require[r];
}
}

View file

@ -157,7 +157,8 @@ exports.eval = (code, options = {}) ->
sandbox.module = _module = new Module(options.modulename || 'eval')
sandbox.require = _require = (path) -> Module._load path, _module, true
_module.filename = sandbox.__filename
_require[r] = require[r] for r in Object.getOwnPropertyNames require when r isnt 'paths'
for r in Object.getOwnPropertyNames require when r not in ['paths', 'arguments', 'caller']
_require[r] = require[r]
# use the same hack node currently uses for their own REPL
_require.paths = _module.paths = Module._nodeModulePaths process.cwd()
_require.resolve = (request) -> Module._resolveFilename request, _module