Expand description
This crate provides an abstraction over Command
to use npm
in a simple and easy package with fluent API.
npm_rs
exposes NpmEnv
to configure the npm
execution enviroment and
Npm
to use said enviroment to execute npm
commands.
Examples
Manual NODE_ENV
setup
// build.rs
use npm_rs::*;
let exit_status = NpmEnv::default()
.with_node_env(&NodeEnv::Production)
.with_env("FOO", "bar")
.init_env()
.install(None)
.run("build")
.exec()?;
Automatic NODE_ENV
setup
// build.rs
use npm_rs::*;
let exit_status = NpmEnv::default()
.with_node_env(&NodeEnv::from_cargo_profile().unwrap_or_default())
.with_env("FOO", "bar")
.init_env()
.install(None)
.run("build")
.exec()?;
Structs
Enums
This enum is used to determine the desired
NODE_ENV
variable value. Its value by Default
is NodeEnv::Development