mirror of
https://github.com/rust-lang/mdBook
synced 2024-12-14 06:42:35 +00:00
Workaround for not being able to run stylus on windows
This commit is contained in:
parent
a84c1ecf33
commit
1d141aa27b
1 changed files with 15 additions and 3 deletions
18
build.rs
18
build.rs
|
@ -6,6 +6,18 @@ use std::path::Path;
|
|||
#[macro_use]
|
||||
extern crate error_chain;
|
||||
|
||||
#[cfg(windows)]
|
||||
mod execs {
|
||||
pub const NPM: &str = "npm.cmd";
|
||||
pub const STYLUS: &str = "stylus.cmd";
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
mod execs {
|
||||
pub const NPM: &str = "npm";
|
||||
pub const STYLUS: &str = "stylus";
|
||||
}
|
||||
|
||||
|
||||
error_chain!{
|
||||
foreign_links {
|
||||
Io(std::io::Error);
|
||||
|
@ -21,7 +33,7 @@ fn program_exists(program: &str) -> Result<()> {
|
|||
}
|
||||
|
||||
fn npm_package_exists(package: &str) -> Result<()> {
|
||||
let status = Command::new("npm")
|
||||
let status = Command::new(execs::NPM)
|
||||
.args(&["list", "-g"])
|
||||
.arg(package)
|
||||
.output();
|
||||
|
@ -55,7 +67,7 @@ fn run() -> Result<()> {
|
|||
|
||||
if let Ok(_) = env::var("CARGO_FEATURE_REGENERATE_CSS") {
|
||||
// Check dependencies
|
||||
Program("npm").exists()?;
|
||||
Program(execs::NPM).exists()?;
|
||||
Program("node").exists()?;
|
||||
Package("nib").exists()?;
|
||||
Package("stylus").exists()?;
|
||||
|
@ -66,7 +78,7 @@ fn run() -> Result<()> {
|
|||
let theme_dir = Path::new(&manifest_dir).join("src/theme/");
|
||||
let stylus_dir = theme_dir.join("stylus/book.styl");
|
||||
|
||||
if !Command::new("stylus")
|
||||
if !Command::new(execs::STYLUS)
|
||||
.arg(stylus_dir)
|
||||
.arg("--out")
|
||||
.arg(theme_dir)
|
||||
|
|
Loading…
Reference in a new issue