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.
Following the contents of
./doc/api/repl.markdown, lines 217-227, I put this inrepl_test.js:Running that, I get
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.jsand./lib/repl.jsand 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.jsshould 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.