fixed `cargo build --features=regenerate-css` on windows 10
also added cargo build --features=regenerate-css to appveyor.yml
This commit is contained in:
parent
a1926bbe8e
commit
d0a6aea3aa
|
@ -1,6 +1,7 @@
|
||||||
environment:
|
environment:
|
||||||
global:
|
global:
|
||||||
PROJECT_NAME: mdBook
|
PROJECT_NAME: mdBook
|
||||||
|
nodejs_version: "6"
|
||||||
matrix:
|
matrix:
|
||||||
# Stable channel
|
# Stable channel
|
||||||
- TARGET: i686-pc-windows-msvc
|
- TARGET: i686-pc-windows-msvc
|
||||||
|
@ -31,12 +32,17 @@ install:
|
||||||
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
|
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
|
||||||
- rustc -Vv
|
- rustc -Vv
|
||||||
- cargo -V
|
- cargo -V
|
||||||
|
- ps: Install-Product node $env:nodejs_version
|
||||||
|
- node --version
|
||||||
|
- npm --version
|
||||||
|
- npm install -g stylus nib
|
||||||
|
|
||||||
build: false
|
build: false
|
||||||
|
|
||||||
# Equivalent to Travis' `script` phase
|
# Equivalent to Travis' `script` phase
|
||||||
test_script:
|
test_script:
|
||||||
- cargo build --verbose
|
- cargo build --verbose
|
||||||
|
- cargo build --verbose --features=regenerate-css
|
||||||
- cargo test --verbose
|
- cargo test --verbose
|
||||||
|
|
||||||
before_deploy:
|
before_deploy:
|
||||||
|
|
25
build.rs
25
build.rs
|
@ -1,6 +1,5 @@
|
||||||
// build.rs
|
// build.rs
|
||||||
|
|
||||||
use std::process::Command;
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -8,13 +7,21 @@ extern crate error_chain;
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
mod execs {
|
mod execs {
|
||||||
pub const NPM: &'static str = "npm.cmd";
|
use std::process::Command;
|
||||||
pub const STYLUS: &'static str = "stylus.cmd";
|
|
||||||
|
pub fn cmd(program: &str) -> Command {
|
||||||
|
let mut cmd = Command::new("cmd");
|
||||||
|
cmd.args(&["/c", program]);
|
||||||
|
cmd
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
mod execs {
|
mod execs {
|
||||||
pub const NPM: &'static str = "npm";
|
use std::process::Command;
|
||||||
pub const STYLUS: &'static str = "stylus";
|
|
||||||
|
pub fn cmd(program: &str) -> Command {
|
||||||
|
Command::new(program)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +32,7 @@ error_chain!{
|
||||||
}
|
}
|
||||||
|
|
||||||
fn program_exists(program: &str) -> Result<()> {
|
fn program_exists(program: &str) -> Result<()> {
|
||||||
Command::new(program)
|
execs::cmd(program)
|
||||||
.arg("-v")
|
.arg("-v")
|
||||||
.output()
|
.output()
|
||||||
.chain_err(|| format!("Please install '{}'!", program))?;
|
.chain_err(|| format!("Please install '{}'!", program))?;
|
||||||
|
@ -33,7 +40,7 @@ fn program_exists(program: &str) -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn npm_package_exists(package: &str) -> Result<()> {
|
fn npm_package_exists(package: &str) -> Result<()> {
|
||||||
let status = Command::new(execs::NPM)
|
let status = execs::cmd("npm")
|
||||||
.args(&["list", "-g"])
|
.args(&["list", "-g"])
|
||||||
.arg(package)
|
.arg(package)
|
||||||
.output();
|
.output();
|
||||||
|
@ -67,7 +74,7 @@ fn run() -> Result<()> {
|
||||||
|
|
||||||
if let Ok(_) = env::var("CARGO_FEATURE_REGENERATE_CSS") {
|
if let Ok(_) = env::var("CARGO_FEATURE_REGENERATE_CSS") {
|
||||||
// Check dependencies
|
// Check dependencies
|
||||||
Program(execs::NPM).exists()?;
|
Program("npm").exists()?;
|
||||||
Program("node").exists().or(Program("nodejs").exists())?;
|
Program("node").exists().or(Program("nodejs").exists())?;
|
||||||
Package("nib").exists()?;
|
Package("nib").exists()?;
|
||||||
Package("stylus").exists()?;
|
Package("stylus").exists()?;
|
||||||
|
@ -78,7 +85,7 @@ fn run() -> Result<()> {
|
||||||
let theme_dir = Path::new(&manifest_dir).join("src/theme/");
|
let theme_dir = Path::new(&manifest_dir).join("src/theme/");
|
||||||
let stylus_dir = theme_dir.join("stylus/book.styl");
|
let stylus_dir = theme_dir.join("stylus/book.styl");
|
||||||
|
|
||||||
if !Command::new(execs::STYLUS)
|
if !execs::cmd("stylus")
|
||||||
.arg(stylus_dir)
|
.arg(stylus_dir)
|
||||||
.arg("--out")
|
.arg("--out")
|
||||||
.arg(theme_dir)
|
.arg(theme_dir)
|
||||||
|
|
Loading…
Reference in New Issue