Pretty REPL
An extension of the Node REPL (repl.REPLServer
) that applies syntax highlighting as the user types.
How to use it
Install the package:
$ npm install --save pretty-repl
Use the package:
const repl = require('pretty-repl');
const options = {
prompt: '→ '
};
repl.start(options);
options
is an an object with the same options as repl.REPLServer
.
Additionally, it's possible to pass an additional colorize
property to the options object:
{
colorize: function (str) {
}
}
Known issues
- The implementation in Node.js versions 11 and 12, this module works by monkey-patching the Interface prototype (
readline
module).
If you use readline
directly somewhere else, you may want to test everything thoroughly. - For Node.js versions older than 11, this module does nothing.
Credits
Pretty repl is inspired and includes code fragments from: