comments in the REPL should have no output, not undefined

This commit is contained in:
Michael Ficarra
2012-04-11 11:43:31 -04:00
parent 60c9b94656
commit 08673261b1
2 changed files with 6 additions and 2 deletions

View File

@@ -98,6 +98,7 @@
run = function(buffer) {
var code, returnValue, _;
buffer = buffer.replace(/(^|[\r\n]+)(\s*)##?(?:[^#\r\n][^\r\n]*|)($|[\r\n])/, "$1$2$3");
buffer = buffer.replace(/[\r\n]+$/, "");
if (multilineMode) {
backlog += "" + buffer + "\n";
@@ -120,7 +121,7 @@
backlog = '';
try {
_ = global._;
returnValue = CoffeeScript["eval"]("_=(undefined\n;" + code + "\n)", {
returnValue = CoffeeScript["eval"]("_=(" + code + "\n)", {
filename: 'repl',
modulename: 'repl'
});

View File

@@ -75,6 +75,9 @@ backlog = ''
# Attempt to evaluate the command. If there's an exception, print it out instead
# of exiting.
run = (buffer) ->
# remove single-line comments
buffer = buffer.replace /(^|[\r\n]+)(\s*)##?(?:[^#\r\n][^\r\n]*|)($|[\r\n])/, "$1$2$3"
# remove trailing newlines
buffer = buffer.replace /[\r\n]+$/, ""
if multilineMode
backlog += "#{buffer}\n"
@@ -94,7 +97,7 @@ run = (buffer) ->
backlog = ''
try
_ = global._
returnValue = CoffeeScript.eval "_=(undefined\n;#{code}\n)", {
returnValue = CoffeeScript.eval "_=(#{code}\n)", {
filename: 'repl'
modulename: 'repl'
}