A library to run npm
commands from your Rust build script.
This library will aid you in executing npm
commands when building your crate/bin,
removing the burden on having to manually do so or by using a tool other than Cargo.
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.
NODE_ENV
setup```rust // build.rs
use npm_rs::*;
let exitstatus = NpmEnv::default() .withnodeenv(&NodeEnv::Production) .withenv("FOO", "bar") .init_env() .install(None) .run("build") .exec()?; ```
NODE_ENV
setup```rust // build.rs
use npm_rs::*;
let exitstatus = NpmEnv::default() .withnodeenv(&NodeEnv::fromcargoprofile().unwrapordefault()) .withenv("FOO", "bar") .init_env() .install(None) .run("build") .exec()?; ```
[NpmEnv
] implements [Clone
] while under a nightly toolchain
when feature nightly
is enabled.
NpmEnv
can be Clone
when the feature nightly
is enabled. This only works under a nightly toolchain.
```toml
[build.dependencies] npm_rs = { version = "*", features = ["nightly"] } ```
Since this is a small library, I would like it to have all the needed features and to be usable before commiting to a v1.0.0.
Contributions are welcome!
npm_rs
is either distributed under MIT or Apache-2.0 license. Choose as you please.