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) { if (!skipCatchall) {
// The catchall for errors // The catchall for errors
try { try {
self.buffered_cmd += cmd; self.buffered_cmd += '\n' + cmd;
// This try is for determining if the command is complete, or should // This try is for determining if the command is complete, or should
// continue onto the next line. // continue onto the next line.
try { try {
// Use evalcx to supply the global context // 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) { if (ret !== undefined) {
context._ = ret; context._ = ret;
self.stream.write(exports.writer(ret) + '\n'); self.stream.write(exports.writer(ret) + '\n');

Loading…
Cancel
Save