0.3.3 • Published 2 years ago

repl-story v0.3.3

Weekly downloads
149
License
MIT
Repository
github
Last release
2 years ago

repl-story

Load history into node repl

npm Build Status codecov License: MIT

Basic Usage

const replHistory = require('repl-story');

const replServer = replHistory('~/.my.wonderful.cli');
// play around in repl
// you can consult history using command .history

Api

replHistory supports differents signatures:

replHistory(repl|replServer, filename); // original signature similar to repl.history
replHistory(filename, [repl|replServer]);
replHistory(options);
replHistory(filename, options);
//  -> REPLServer

Here are the different possible params:

  • filename or historyFile: the path toward the history file. filename is mandatory. However you can skip it and provide it via the options argument as the filename property (you can also use the alias historyFile).
  • replServer or repl: either the repl module, or a ReplServer. default the require('repl') builtin library

  • an options object, this give you better control over repl and repl-story configuration. This is a plain old js object that support the following properties

replHistory() return the REPLServer instance you provided, or otherwise the one it started.

Note: replHistory instrument the repl server so that when it closes the history file is closed properly. If you want for this to be complete, you can listen the end-of-story event on the replServer itself.

'Complex' Example

Here is an example to illustrate how to configure repl-story:

const repl = require('repl');
const replHistory = require('repl-story');

const replServer = replHistory({
    repl,
    filename: '~/.my.cli',
    record: false, // load history but do no record it. (equivalent to 'noRecord: true')
    noCreate: true, // disable creation if missing. (equivalent to 'create: false')
    prompt: ':> ' // options are forwarded to repl.start() if no provided replServer
});

Acknowledgment

This started as the adaptation of repl.history to current node Apis.

And why story? repl-history was already taken :wink:

0.3.3

2 years ago

0.3.2

3 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.1

4 years ago

0.2.2

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago