5 个版本 (1 个稳定版)

1.0.0 2022年11月16日
0.2.1 2021年9月3日
0.1.2 2021年8月6日
0.1.1 2021年6月9日
0.1.0 2021年5月31日

#211 in 构建工具

Download history • Rust 包仓库 3728/week @ 2024-03-14 • Rust 包仓库 4027/week @ 2024-03-21 • Rust 包仓库 4617/week @ 2024-03-28 • Rust 包仓库 3584/week @ 2024-04-04 • Rust 包仓库 3975/week @ 2024-04-11 • Rust 包仓库 3889/week @ 2024-04-18 • Rust 包仓库 3026/week @ 2024-04-25 • Rust 包仓库 2578/week @ 2024-05-02 • Rust 包仓库 2849/week @ 2024-05-09 • Rust 包仓库 2841/week @ 2024-05-16 • Rust 包仓库 2086/week @ 2024-05-23 • Rust 包仓库 1188/week @ 2024-05-30 • Rust 包仓库 972/week @ 2024-06-06 • Rust 包仓库 1195/week @ 2024-06-13 • Rust 包仓库 1087/week @ 2024-06-20 • Rust 包仓库 859/week @ 2024-06-27 • Rust 包仓库

4,405 每月下载量
用于 16 个crate (5 个直接使用)

MIT/Apache

13KB
157

npm_rs

License (MIT OR APACHE) GitHub Workflow Status Crates.io docs.rs

一个从Rust构建脚本中运行npm命令的库。

文档

此库将帮助您在构建crate/bin时执行npm命令,无需手动执行或在非Cargo的工具中执行。

此crate通过提供流畅的API,为使用npm提供了一个简单的抽象层。

npm_rs通过NpmEnv公开配置npm执行环境,并通过Npm使用此环境来执行npm命令。

示例

手动NODE_ENV设置

// 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()?;

自动NODE_ENV设置

// 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()?;

许可证

npm_rs要么在MIT许可证下,要么在Apache-2.0许可证下分发。请随意选择。

依赖项