-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
Description
- Version: v5.7.0
- Platform: Linux arch-desktop 4.4.1-2-ARCH deps: update openssl to 1.0.1j #1 SMP PREEMPT Wed Feb 3 13:12:33 UTC 2016 x86_64 GNU/Linux
Following the contents of ./doc/api/repl.markdown, lines 217-227, I put this in repl_test.js:
const repl = require('repl');
var replServer = repl.start();
replServer.defineCommand('sayhello', {
help: 'Say hello',
action: function(name) {
this.write(`Hello, ${name}!\n`);
this.displayPrompt();
}
});
Running that, I get
repl.js:198
throw new Error('An options Object, or a prompt String are required');
On line 252 of ./doc/api/repl.markdown, it is noted that prompt should default to > if an options object is passed in, but not what should happen if it is called without arguments.
I took a look at ./lib/readline.js and ./lib/repl.js and the culprit for the code snippet failing (if the docs represent the intended functionality) is line 197-198 of ./lib/repl.js.
Either way, it seems to me that either the docs should be updated to reflect the code, or those lines in ./lib/repl.js should be removed to make it fall back to an empty object and thus the default > prompt. No PR submitted because I don't know which of the directions to go in.