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.
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 aspath
- node_modules
lodash
will be loaded aslodash
- node_modules
bluebird
will be loaded asPromise
- local file
./file.js
will be loaded asfile
- local file
./other_file.js
will be loaded asfile
and will overwrite previously loaded file
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.
When evaling returns promise, it will not be outputted in «raw view» (like { then: … }
), instead REPL will await for its fulfilling.
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.
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
, usedir()
to inspect them.
- Many of functions are inserted directly in
- Partially-applicated
log
function vialogpart
. - Function's signatures and source code via
signature
(aliassg
) andsourceCode
(aliassrc
). dir
function for navigating objects (enums, not-enums, own, from prototype chain).
If you do not want utilities to be loaded into REPL, pass --clean
option.
$ repl.js --clean
Use repljs
executable instead of repl.js
in your cmd
.
MIT. © Strider, 2013 — 2017.