Skip to content

StreetStrider/repl.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

repl.js license|mit npm|repl.js

Node.js REPL with promise support & CLI module requiring.

This module is a drop-in replacement for node std repl. Can be used as shell & via API.

features

on-start requiring

Specify modules (with optional aliases) you want to be loaded into REPL onstart.

$ repl.js path lodash Promise=bluebird ./file.js file=./other_file.js

Here:

  • std module path will be loaded as path
  • node_modules lodash will be loaded as lodash
  • node_modules bluebird will be loaded as Promise
  • local file ./file.js will be loaded as file
  • local file ./other_file.js will be loaded as file and will overwrite previously loaded file

execute & enter interactive

Supply script or filename to execute. After executing REPL will be started with script's results.

# execute script and inspect its results in interactive mode
$ repl.js -e 'var x = 1;'

# execute file
$ repl.js -f script.js

If you just want execute script and do not enter interactive mode (just like node do), you can pass -q option.

promises

When evaling returns promise, it will not be outputted in «raw view» (like { then: … }), instead REPL will await for its fulfilling.

robust require

All modules are resolved relatively to workdir which REPL was started, and not relatively to REPL source files. So you can start repl from your project's directory and retrieve modules you need with proper versions.

useful utils

In REPL some features are loaded automatically:

  • Colored console via console (console-ultimate).
    • Take a moment to look through console-ultimate's features. It has support for hi-res timers, better stack traces, tables, grouping and neat coloring by default.
  • Colors via colors (cli-color).
  • Common-use utilities from aux.js, functional stuff (aux.js).
    • Many of functions are inserted directly in global, use dir() to inspect them.
  • Partially-applicated log function via logpart.
  • Function's signatures and source code via signature (alias sg) and sourceCode (alias src).
  • dir function for navigating objects (enums, not-enums, own, from prototype chain).

clean environment

If you do not want utilities to be loaded into REPL, pass --clean option.

$ repl.js --clean

note for windows users

Use repljs executable instead of repl.js in your cmd.

license

MIT. © Strider, 2013 — 2017.