Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
electronstudio committed Jul 30, 2024
1 parent b975113 commit ef6f69f
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,27 @@ fn build_ffmpeg(dist_dir: &Path) {
}
}


fn build_www() {
let www_dir = Path::new("www");

#[cfg(not(target_os = "windows"))]
let shell = "bash";

#[cfg(not(target_os = "windows"))]
let shell_flag = "-c";

#[cfg(target_os = "windows")]
let shell = "cmd";

#[cfg(target_os = "windows")]
let shell_flag = "/c";


// try `pnpm` first, then `npm`
if !www_dir.join("node_modules").exists() {
let pnpm_install_success = match Command::new("bash")
.args(["-c", "pnpm install"])
let pnpm_install_success = match Command::new(shell)
.args([shell_flag, "pnpm install"])
.current_dir(www_dir)
.status()
{
Expand All @@ -41,8 +55,8 @@ fn build_www() {
};

if !pnpm_install_success {
let npm_install_result = Command::new("bash")
.args(["-c", "npm install"])
let npm_install_result = Command::new(shell)
.args([shell_flag, "npm install"])
.current_dir(www_dir)
.status()
.expect("Failed to run npm or pnpm!");
Expand All @@ -56,8 +70,8 @@ fn build_www() {
}
}

let build_result = Command::new("bash")
.args(["-c", "npm run build"])
let build_result = Command::new(shell)
.args([shell_flag, "npm run build"])
.current_dir(www_dir)
.status()
.expect("Failed to build www!");
Expand All @@ -70,6 +84,8 @@ fn build_www() {
}
}



fn main() {
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();

Expand Down

0 comments on commit ef6f69f

Please sign in to comment.