Skip to content

Commit a6a7c95

Browse files
authored
Merge pull request #343 from budziq/appveyor_css
fixed `cargo build --features=regenerate-css` on win 10 / nightly
2 parents 2f3c14d + d0a6aea commit a6a7c95

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

appveyor.yml

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
environment:
22
global:
33
PROJECT_NAME: mdBook
4+
nodejs_version: "6"
45
matrix:
56
# Stable channel
67
- TARGET: i686-pc-windows-msvc
@@ -31,12 +32,17 @@ install:
3132
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
3233
- rustc -Vv
3334
- cargo -V
35+
- ps: Install-Product node $env:nodejs_version
36+
- node --version
37+
- npm --version
38+
- npm install -g stylus nib
3439

3540
build: false
3641

3742
# Equivalent to Travis' `script` phase
3843
test_script:
3944
- cargo build --verbose
45+
- cargo build --verbose --features=regenerate-css
4046
- cargo test --verbose
4147

4248
before_deploy:

build.rs

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
// build.rs
22

3-
use std::process::Command;
43
use std::env;
54
use std::path::Path;
65
#[macro_use]
76
extern crate error_chain;
87

98
#[cfg(windows)]
109
mod execs {
11-
pub const NPM: &'static str = "npm.cmd";
12-
pub const STYLUS: &'static str = "stylus.cmd";
10+
use std::process::Command;
11+
12+
pub fn cmd(program: &str) -> Command {
13+
let mut cmd = Command::new("cmd");
14+
cmd.args(&["/c", program]);
15+
cmd
16+
}
1317
}
1418
#[cfg(not(windows))]
1519
mod execs {
16-
pub const NPM: &'static str = "npm";
17-
pub const STYLUS: &'static str = "stylus";
20+
use std::process::Command;
21+
22+
pub fn cmd(program: &str) -> Command {
23+
Command::new(program)
24+
}
1825
}
1926

2027

@@ -25,15 +32,15 @@ error_chain!{
2532
}
2633

2734
fn program_exists(program: &str) -> Result<()> {
28-
Command::new(program)
35+
execs::cmd(program)
2936
.arg("-v")
3037
.output()
3138
.chain_err(|| format!("Please install '{}'!", program))?;
3239
Ok(())
3340
}
3441

3542
fn npm_package_exists(package: &str) -> Result<()> {
36-
let status = Command::new(execs::NPM)
43+
let status = execs::cmd("npm")
3744
.args(&["list", "-g"])
3845
.arg(package)
3946
.output();
@@ -67,7 +74,7 @@ fn run() -> Result<()> {
6774

6875
if let Ok(_) = env::var("CARGO_FEATURE_REGENERATE_CSS") {
6976
// Check dependencies
70-
Program(execs::NPM).exists()?;
77+
Program("npm").exists()?;
7178
Program("node").exists().or(Program("nodejs").exists())?;
7279
Package("nib").exists()?;
7380
Package("stylus").exists()?;
@@ -78,7 +85,7 @@ fn run() -> Result<()> {
7885
let theme_dir = Path::new(&manifest_dir).join("src/theme/");
7986
let stylus_dir = theme_dir.join("stylus/book.styl");
8087

81-
if !Command::new(execs::STYLUS)
88+
if !execs::cmd("stylus")
8289
.arg(stylus_dir)
8390
.arg("--out")
8491
.arg(theme_dir)

0 commit comments

Comments
 (0)