Crate rusty_nodejs_repl

Source
Expand description

This crate lets you run arbitrary code in a Node.js REPL from Rust. Use Config to setup the REPL and use Repl to interact with it.

let mut repl: Repl = Config::build()?.start()?;
let result = repl.run("console.log('Hello, world!');").await?;
assert_eq!(result, b"Hello, world!\n");
repl.stop().await?;

The REPL is run in it’s own tempfile::TempDir. So any files created alongside it will be cleaned up on exit.

Structs§

Config
Configurating for Repl. Usually you will want to setup the REPL context by importing some modules and doing some setup. Then maybe, run some teardown code after the REPL closes. Do this by giving JavaScript strings to Config::imports, Config::before, and Config::after fields.
ConfigBuilder
Builder for Config.
Repl
Interface to the Node.js REPL. Send code with Repl::run, stop it with Repl::stop.

Enums§

ConfigBuilderError
Error type for ConfigBuilder
Error