JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 67367
  • Score
    100M100P100Q160028F
  • License MIT

Extends repl.REPLServer to allow for a colorize function

Package Exports

  • pretty-repl

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pretty-repl) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Pretty REPL

An extension of the Node REPL (repl.REPLServer) that applies syntax highlighting as the user types.

Pretty REPL Screenshot

How to use it

Install the package:

$ npm install --save pretty-repl

Use the package:

const PrettyREPLServer = require('.');

const options = {
    prompt: '→ '
};

new PrettyREPLServer(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) {
        // str is the the string in input.
        // the function should return the string that has been colorized to output in the REPL.
    }
}

Known issues

  • Only works properly on Node 13+. Unfortunately, Node 12 does some trickery when starting the REPL with repl.start() which makes it behave differently than when the REPL is started with new repl.REPLServer(). When REPLServer is instantiated directly, everyhting works fine until the REPL needs to throw an error. This is not true only for FancyREPLServer, it's the same also for the default REPLServer that ships with Node.

Credits

Pretty repl is inspired and includes code fragments from: