mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
Merge pull request #1309 from TrevorBurnham/sandbox.
Fixing unavailability of `global` properties on REPL
This commit is contained in:
@@ -75,15 +75,13 @@
|
||||
require: require,
|
||||
module: {
|
||||
exports: {}
|
||||
},
|
||||
global: {}
|
||||
}
|
||||
};
|
||||
for (g in global) {
|
||||
sandbox.global[g] = global[g];
|
||||
sandbox[g] = global[g];
|
||||
}
|
||||
sandbox.global.global = sandbox.global;
|
||||
sandbox.global.root = sandbox.global;
|
||||
sandbox.global.GLOBAL = sandbox.global;
|
||||
sandbox.global = sandbox;
|
||||
sandbox.global.global = sandbox.global.root = sandbox.global.GLOBAL = sandbox;
|
||||
}
|
||||
sandbox.__filename = options.filename || 'eval';
|
||||
sandbox.__dirname = path.dirname(sandbox.__filename);
|
||||
|
||||
10
lib/repl.js
10
lib/repl.js
@@ -21,15 +21,13 @@
|
||||
require: require,
|
||||
module: {
|
||||
exports: {}
|
||||
},
|
||||
global: {}
|
||||
}
|
||||
};
|
||||
for (g in global) {
|
||||
sandbox.global[g] = global[g];
|
||||
sandbox[g] = global[g];
|
||||
}
|
||||
sandbox.global.global = sandbox.global;
|
||||
sandbox.global.root = sandbox.global;
|
||||
sandbox.global.GLOBAL = sandbox.global;
|
||||
sandbox.global = sandbox;
|
||||
sandbox.global.global = sandbox.global.root = sandbox.global.GLOBAL = sandbox;
|
||||
return function(buffer) {
|
||||
var code, val;
|
||||
code = backlog += '\n' + buffer.toString();
|
||||
|
||||
@@ -85,11 +85,9 @@ exports.eval = (code, options = {}) ->
|
||||
sandbox =
|
||||
require: require
|
||||
module : { exports: {} }
|
||||
global : {}
|
||||
sandbox.global[g] = global[g] for g of global
|
||||
sandbox.global.global = sandbox.global
|
||||
sandbox.global.root = sandbox.global
|
||||
sandbox.global.GLOBAL = sandbox.global
|
||||
sandbox[g] = global[g] for g of global
|
||||
sandbox.global = sandbox
|
||||
sandbox.global.global = sandbox.global.root = sandbox.global.GLOBAL = sandbox
|
||||
sandbox.__filename = options.filename || 'eval'
|
||||
sandbox.__dirname = path.dirname sandbox.__filename
|
||||
js = compile "_=(#{code.trim()})", options
|
||||
|
||||
@@ -35,11 +35,9 @@ run = do ->
|
||||
sandbox =
|
||||
require: require
|
||||
module : { exports: {} }
|
||||
global : {}
|
||||
sandbox.global[g] = global[g] for g of global
|
||||
sandbox.global.global = sandbox.global
|
||||
sandbox.global.root = sandbox.global
|
||||
sandbox.global.GLOBAL = sandbox.global
|
||||
sandbox[g] = global[g] for g of global
|
||||
sandbox.global = sandbox
|
||||
sandbox.global.global = sandbox.global.root = sandbox.global.GLOBAL = sandbox
|
||||
(buffer) ->
|
||||
code = backlog += '\n' + buffer.toString()
|
||||
if code[code.length - 1] is '\\'
|
||||
|
||||
Reference in New Issue
Block a user