File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,6 @@ stdin.prototype.readline = function(callback) {
7676function REPL ( ) {
7777 this . input = new stdin ( ) ;
7878 this . _prompt_msg = new Buffer ( '> ' ) ;
79- this . _repl_context = { } ;
8079} ;
8180
8281REPL . prototype . print_prompt = function ( ) {
@@ -87,7 +86,8 @@ REPL.prototype.print_prompt = function() {
8786REPL . prototype . run_code = function ( line ) {
8887 var result ;
8988 try {
90- result = eval . call ( this . _repl_context , line ) ;
89+ /* Doing indirect eval to force everything into the global object. */
90+ result = eval . call ( undefined , line ) ;
9191 console . log ( result ) ;
9292 } catch ( ex ) {
9393 console . error ( ex ) ;
@@ -100,6 +100,11 @@ REPL.prototype.process_line = function(line) {
100100} ;
101101
102102REPL . prototype . start = function ( ) {
103+ /* Expose the "require" method for the global object.
104+ * This way the "eval" call can access it correctly.
105+ */
106+ global . require = require ;
107+
103108 this . print_prompt ( ) ;
104109 this . input . start ( ) ;
105110 this . input . readline ( this . process_line . bind ( this ) ) ;
You can’t perform that action at this time.
0 commit comments