repl: fixing undefined
in invalid REPL keyword error
When an invalid REPL keyword is used, we actually print `undefined` as well in the console. > process.version 'v2.3.4' > .invalid_repl_command Invalid REPL keyword undefined > This patch prevents printing `undefined` in this case. > process.version 'v2.3.5-pre' > .invalid_repl_command Invalid REPL keyword > PR-URL: https://github.com/nodejs/io.js/pull/2163 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
This commit is contained in:
parent
a3c1b9720e
commit
77fa385e5d
@ -342,7 +342,12 @@ function REPLServer(prompt,
|
|||||||
self.bufferedCommand = '';
|
self.bufferedCommand = '';
|
||||||
|
|
||||||
// If we got any output - print it (if no error)
|
// If we got any output - print it (if no error)
|
||||||
if (!e && (!self.ignoreUndefined || ret !== undefined)) {
|
if (!e &&
|
||||||
|
// When an invalid REPL command is used, error message is printed
|
||||||
|
// immediately. We don't have to print anything else. So, only when
|
||||||
|
// the second argument to this function is there, print it.
|
||||||
|
arguments.length === 2 &&
|
||||||
|
(!self.ignoreUndefined || ret !== undefined)) {
|
||||||
self.context._ = ret;
|
self.context._ = ret;
|
||||||
self.outputStream.write(self.writer(ret) + '\n');
|
self.outputStream.write(self.writer(ret) + '\n');
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,11 @@ function error_test() {
|
|||||||
{ client: client_unix, send: 'url.format("http://google.com")',
|
{ client: client_unix, send: 'url.format("http://google.com")',
|
||||||
expect: 'http://google.com/' },
|
expect: 'http://google.com/' },
|
||||||
{ client: client_unix, send: 'var path = 42; path',
|
{ client: client_unix, send: 'var path = 42; path',
|
||||||
expect: '42' }
|
expect: '42' },
|
||||||
|
// this makes sure that we don't print `undefined` when we actually print
|
||||||
|
// the error message
|
||||||
|
{ client: client_unix, send: '.invalid_repl_command',
|
||||||
|
expect: 'Invalid REPL keyword\n' + prompt_unix },
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user