mirror of https://github.com/nodejs/node.git
repl: better empty line handling
In REPL, if we try to evaluate an empty line, we get `undefined`. > process.version 'v2.3.4' > undefined > undefined > This patch prevents `undefined` from printing if the string is empty. > process.version 'v2.3.5-pre' > > > PR-URL: https://github.com/nodejs/io.js/pull/2163 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>pull/2163/merge
parent
81ea52aa01
commit
afd7e37ee0
|
@ -357,7 +357,7 @@ function REPLServer(prompt,
|
|||
}
|
||||
}
|
||||
|
||||
if (!skipCatchall) {
|
||||
if (!skipCatchall && (cmd || (!cmd && self.bufferedCommand))) {
|
||||
var evalCmd = self.bufferedCommand + cmd;
|
||||
if (/^\s*\{/.test(evalCmd) && /\}\s*$/.test(evalCmd)) {
|
||||
// It's confusing for `{ a : 1 }` to be interpreted as a block
|
||||
|
|
|
@ -225,6 +225,13 @@ function error_test() {
|
|||
// using REPL command "help" within a string literal should still work
|
||||
{ client: client_unix, send: '\'thefourth\\\n.help\neye\'',
|
||||
expect: /'thefourtheye'/ },
|
||||
// empty lines in the REPL should be allowed
|
||||
{ client: client_unix, send: '\n\r\n\r\n',
|
||||
expect: prompt_unix + prompt_unix + prompt_unix },
|
||||
// empty lines in the string literals should not affect the string
|
||||
{ client: client_unix, send: '\'the\\\n\\\nfourtheye\'\n',
|
||||
expect: prompt_multiline + prompt_multiline +
|
||||
'\'thefourtheye\'\n' + prompt_unix },
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue