Skip to content

repl: better REPL commands detection

Fixes the problem shown in https://github.com/nodejs/io.js/pull/2246

The REPL module, treats any line which starts with a dot character as a REPL command and this limits the ability to use function calls in the next lines to improve readability.

This patch checks if the current line starts with . and then a series of lowercase letters and then any characters.

For example:

> process.version
'v2.4.0'
> function sum(arr) {
... return arr
...     .reduce(function(c, x) { return x + c; });
Invalid REPL keyword
undefined

but then, this patches allows this:

> process.version
'v2.4.1-pre'
> function sum(arr) {
... return arr
...     .reduce(function(c, x) { return x + c; });
... }
undefined

Merge request reports

Loading