power-repl
A powerful REPL with await and remote support.
Last updated a day ago by hyurl .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install power-repl 
SYNC missed versions from official npm registry.

PowerREPL

A powerful REPL with await and remote support.

Node.js REPL is a very useful tool, however, if you have a program, say a server running in an individual process, how do you know the state of the process? how can you interact with that server? The built-in REPL doesn't provide that kind of ability, so here comes PowerREPL.

Example

To use PowerREPL, you should serve an REPL server in your server process, say an an HTTP server, which might look like this:

// app.js
const http = require("http");
const { serve } = require("power-repl");

const server = http.createServer((req, res) => {
     // ...
}).listen(80);

serve("/tmp/my-app/repl.sock");

And then connect to the server process in another process.

// repl.js
const { connect } = require("power-repl");

connect("/tmp/my-app/repl.sock");

After you started the HTTP server (node app), you can then interact with the server via REPL client (node repl). everything is just like doing on the server process itself.

API

function serve(path: string): Promise<net.Server>;
function serve(options: net.ListenOptions): Promise<net.Server>;

function connect(path: string): Promise<net.Socket>;
function connect(options: ConnectOptions): Promise<net.Socket>;

export interface ConnectOptions {
    [x: string]: any;
    path?: string;
    port?: number;
    host?: string;
    timeout?: number;
    prompt?: string;
    history?: string;
    historySize?: number;
    removeHistoryDuplicates?: boolean;
    noStdout?: boolean;
}

As you can see from the API specification, you can even serve and connect to the REPL server through the internet.

await Support

Backed by node-repl-await, you can freely use any await statement in PowerREPL, which really helps a lot.

Persistent History

By default, PowerREPL will persist history between REPL sessions by saving inputs to a .power_repl_history file located in the current working directory. This behavior can be configured by providing the history option when connect.

TODO

  • Tab key auto-complete

Current Tags

  • 0.1.7                                ...           latest (a day ago)

8 Versions

  • 0.1.7                                ...           a day ago
  • 0.1.6                                ...           3 months ago
  • 0.1.5                                ...           3 months ago
  • 0.1.4                                ...           3 months ago
  • 0.1.3                                ...           3 months ago
  • 0.1.2                                ...           3 months ago
  • 0.1.1                                ...           3 months ago
  • 0.1.0                                ...           3 months ago
Maintainers (1)
Downloads
Today 0
This Week 22
This Month 108
Last Day 1
Last Week 86
Last Month 2
Dependencies (6)
Dev Dependencies (2)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |