diff --git a/create-rust-app_cli/src/content/project.rs b/create-rust-app_cli/src/content/project.rs index 85b95baa..914eaf0c 100644 --- a/create-rust-app_cli/src/content/project.rs +++ b/create-rust-app_cli/src/content/project.rs @@ -80,12 +80,12 @@ fn add_bins_to_cargo_toml(project_dir: &std::path::PathBuf) -> Result<(), std::i let append_to_toml = format!( r#" [[bin]] -name = "fullstack" -path = ".cargo/bin/fullstack.rs" +name = "run_yarn_fullstack" +path = ".cargo/bin/run_yarn_fullstack.rs" [[bin]] -name = "tsync" -path = ".cargo/bin/tsync.rs" +name = "run_yarn_tsync" +path = ".cargo/bin/run_yarn_tsync.rs" [[bin]] name = "{project_name}" diff --git a/create-rust-app_cli/template/.cargo/bin/fullstack.rs b/create-rust-app_cli/template/.cargo/bin/run_yarn_fullstack.rs similarity index 79% rename from create-rust-app_cli/template/.cargo/bin/fullstack.rs rename to create-rust-app_cli/template/.cargo/bin/run_yarn_fullstack.rs index ba316988..94da7c6a 100644 --- a/create-rust-app_cli/template/.cargo/bin/fullstack.rs +++ b/create-rust-app_cli/template/.cargo/bin/run_yarn_fullstack.rs @@ -1,6 +1,12 @@ use std::io; use std::process::Command; +#[cfg(windows)] +pub const YARN_COMMAND: &'static str = "yarn.cmd"; + +#[cfg(not(windows))] +pub const YARN_COMMAND: &'static str = "yarn"; + pub fn main() -> Result<(), io::Error> { if !create_rust_app::net::is_port_free(21012) { println!("========================================================"); @@ -10,7 +16,7 @@ pub fn main() -> Result<(), io::Error> { panic!("Port 21012 is taken but is required for development!") } - Command::new("yarn") + Command::new(YARN_COMMAND) .arg("fullstack") .current_dir("frontend") .spawn() diff --git a/create-rust-app_cli/template/.cargo/bin/tsync.rs b/create-rust-app_cli/template/.cargo/bin/run_yarn_tsync.rs similarity index 70% rename from create-rust-app_cli/template/.cargo/bin/tsync.rs rename to create-rust-app_cli/template/.cargo/bin/run_yarn_tsync.rs index e79849c0..de468adc 100644 --- a/create-rust-app_cli/template/.cargo/bin/tsync.rs +++ b/create-rust-app_cli/template/.cargo/bin/run_yarn_tsync.rs @@ -2,12 +2,18 @@ use std::io; use std::process::Command; use std::path::PathBuf; +#[cfg(windows)] +pub const YARN_COMMAND: &'static str = "yarn.cmd"; + +#[cfg(not(windows))] +pub const YARN_COMMAND: &'static str = "yarn"; + pub fn main() -> Result<(), io::Error> { let dir = env!("CARGO_MANIFEST_DIR"); println!("Running `yarn tsync` in `$project_dir/frontend/`..."); - Command::new("yarn") + Command::new(YARN_COMMAND) .arg("tsync") .current_dir(PathBuf::from_iter([dir, "frontend"])) .spawn() diff --git a/create-rust-app_cli/template/.cargo/config b/create-rust-app_cli/template/.cargo/config index 662714ca..ed5e15fc 100644 --- a/create-rust-app_cli/template/.cargo/config +++ b/create-rust-app_cli/template/.cargo/config @@ -1,6 +1,6 @@ [alias] -fullstack="run --bin fullstack" -tsync="run --bin tsync" +fullstack="run --bin run_yarn_fullstack" +tsync="run --bin run_yarn_tsync" [build] target-dir=".cargo/.build"