Browse Source

Improve how REPL commands are evaled

Before:
> {a: 1}
1
> (function() {
...   // foo
...   return 1;
... })();
...

Now:
> {a: 1}
{ a : 1 }
> (function() {
...   // foo
...   return 1;
... })();
1
>
v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
b45698e676
  1. 4
      lib/repl.js

4
lib/repl.js

@ -104,12 +104,12 @@ function REPLServer(prompt, stream) {
if (!skipCatchall) {
// The catchall for errors
try {
self.buffered_cmd += cmd;
self.buffered_cmd += '\n' + cmd;
// This try is for determining if the command is complete, or should
// continue onto the next line.
try {
// Use evalcx to supply the global context
var ret = evalcx(self.buffered_cmd, context, 'repl');
var ret = evalcx('(' + self.buffered_cmd + ')', context, 'repl');
if (ret !== undefined) {
context._ = ret;
self.stream.write(exports.writer(ret) + '\n');

Loading…
Cancel
Save