|
@ -64,10 +64,10 @@ module.paths = require('module')._nodeModulePaths(module.filename); |
|
|
exports.writer = util.inspect; |
|
|
exports.writer = util.inspect; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function REPLServer(prompt, stream, options) { |
|
|
function REPLServer(prompt, stream) { |
|
|
var self = this; |
|
|
var self = this; |
|
|
|
|
|
|
|
|
self.eval = options && options.eval || function(code, context, file, cb) { |
|
|
self.eval = function(code, context, file, cb) { |
|
|
try { |
|
|
try { |
|
|
var err, result = vm.runInContext(code, context, file); |
|
|
var err, result = vm.runInContext(code, context, file); |
|
|
} catch (e) { |
|
|
} catch (e) { |
|
@ -186,15 +186,17 @@ function REPLServer(prompt, stream, options) { |
|
|
|
|
|
|
|
|
// Now as statement without parens.
|
|
|
// Now as statement without parens.
|
|
|
function tryExpr(ret) { |
|
|
function tryExpr(ret) { |
|
|
self.eval(self.bufferedCommand, self.context, |
|
|
|
|
|
'repl', function(e, ret) { |
|
|
self.bufferedCommand = ''; |
|
|
|
|
|
|
|
|
if (ret !== undefined) { |
|
|
if (ret !== undefined) { |
|
|
self.context._ = ret; |
|
|
self.context._ = ret; |
|
|
self.outputStream.write(exports.writer(ret) + '\n'); |
|
|
self.outputStream.write(exports.writer(ret) + '\n'); |
|
|
|
|
|
return finish(null); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
self.bufferedCommand = ''; |
|
|
self.eval(self.bufferedCommand, self.context, |
|
|
|
|
|
'repl', function(e, ret) { |
|
|
|
|
|
|
|
|
if (e) { |
|
|
if (e) { |
|
|
// instanceof doesn't work across context switches.
|
|
|
// instanceof doesn't work across context switches.
|
|
@ -467,13 +469,16 @@ REPLServer.prototype.complete = function(line, callback) { |
|
|
filter = expr + '.' + filter; |
|
|
filter = expr + '.' + filter; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
finish(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
return; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// If reach this point - work like sync
|
|
|
// If reach this point - work like sync
|
|
|
finish(null, ret); |
|
|
finish(null); |
|
|
function finish(err, ret) { |
|
|
function finish(err, ret) { |
|
|
if (err) throw err; |
|
|
if (err) throw err; |
|
|
|
|
|
|
|
|