Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed cargo build --features=regenerate-css on win 10 / nightly #343

Merged
merged 1 commit into from
Sep 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
environment:
global:
PROJECT_NAME: mdBook
nodejs_version: "6"
matrix:
# Stable channel
- TARGET: i686-pc-windows-msvc
Expand Down Expand Up @@ -31,12 +32,17 @@ install:
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
- rustc -Vv
- cargo -V
- ps: Install-Product node $env:nodejs_version
- node --version
- npm --version
- npm install -g stylus nib

build: false

# Equivalent to Travis' `script` phase
test_script:
- cargo build --verbose
- cargo build --verbose --features=regenerate-css
- cargo test --verbose

before_deploy:
Expand Down
25 changes: 16 additions & 9 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
// build.rs

use std::process::Command;
use std::env;
use std::path::Path;
#[macro_use]
extern crate error_chain;

#[cfg(windows)]
mod execs {
pub const NPM: &'static str = "npm.cmd";
pub const STYLUS: &'static str = "stylus.cmd";
use std::process::Command;

pub fn cmd(program: &str) -> Command {
let mut cmd = Command::new("cmd");
cmd.args(&["/c", program]);
cmd
}
}
#[cfg(not(windows))]
mod execs {
pub const NPM: &'static str = "npm";
pub const STYLUS: &'static str = "stylus";
use std::process::Command;

pub fn cmd(program: &str) -> Command {
Command::new(program)
}
}


Expand All @@ -25,15 +32,15 @@ error_chain!{
}

fn program_exists(program: &str) -> Result<()> {
Command::new(program)
execs::cmd(program)
.arg("-v")
.output()
.chain_err(|| format!("Please install '{}'!", program))?;
Ok(())
}

fn npm_package_exists(package: &str) -> Result<()> {
let status = Command::new(execs::NPM)
let status = execs::cmd("npm")
.args(&["list", "-g"])
.arg(package)
.output();
Expand Down Expand Up @@ -67,7 +74,7 @@ fn run() -> Result<()> {

if let Ok(_) = env::var("CARGO_FEATURE_REGENERATE_CSS") {
// Check dependencies
Program(execs::NPM).exists()?;
Program("npm").exists()?;
Program("node").exists().or(Program("nodejs").exists())?;
Package("nib").exists()?;
Package("stylus").exists()?;
Expand All @@ -78,7 +85,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(execs::STYLUS)
if !execs::cmd("stylus")
.arg(stylus_dir)
.arg("--out")
.arg(theme_dir)
Expand Down