Skip to content

Call yarn as "yarn.cmd" on Windows (fixes #53) #65

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

Closed
wants to merge 2 commits into from
Closed
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
8 changes: 4 additions & 4 deletions create-rust-app_cli/src/content/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Comment on lines -83 to +84
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this rename necessary or were you trying to maintain the naming convention with tsync?
if it's not necessary, let's undo this change.


[[bin]]
name = "tsync"
path = ".cargo/bin/tsync.rs"
name = "run_yarn_tsync"
path = ".cargo/bin/run_yarn_tsync.rs"
Comment on lines -87 to +88
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8.1.0 doesn't run tsync via yarn anymore nor does it use the global tsync binary.

Since you can uninstall tsync via cargo uninstall tsync and use cargo tsync normally, do you think this resolves the issue?


[[bin]]
name = "{project_name}"
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Comment on lines +4 to +8
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perfect!~


pub fn main() -> Result<(), io::Error> {
if !create_rust_app::net::is_port_free(21012) {
println!("========================================================");
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Comment on lines +5 to +16
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you rebase, these changes won't be necessary :)

.arg("tsync")
.current_dir(PathBuf::from_iter([dir, "frontend"]))
.spawn()
Expand Down
4 changes: 2 additions & 2 deletions create-rust-app_cli/template/.cargo/config
Original file line number Diff line number Diff line change
@@ -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"