-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #180 from ikatson/webui-exclude-dist
Generate webui dist files as part of build.rs
- Loading branch information
Showing
9 changed files
with
53 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use anyhow::{bail, Context}; | ||
use std::path::Path; | ||
use std::process::Command; | ||
|
||
fn run_cmd(cwd: &Path, cmd: &str) -> anyhow::Result<()> { | ||
#[cfg(target_os = "windows")] | ||
let (shell, shell_args) = ("powershell", ["-command"].as_slice()); | ||
#[cfg(not(target_os = "windows"))] | ||
let (shell, shell_args) = ("bash", ["-c"].as_slice()); | ||
|
||
// Run "npm install" in the webui directory | ||
let output = Command::new(shell) | ||
.args(shell_args) | ||
.arg(cmd) | ||
.current_dir(cwd) | ||
.output() | ||
.with_context(|| format!("Failed to execute {} in {:?}", cmd, cwd))?; | ||
|
||
if !output.status.success() { | ||
bail!( | ||
"\"{}\" failed\n\nstderr: {}\n\nstdout: {}", | ||
cmd, | ||
String::from_utf8_lossy(&output.stderr), | ||
String::from_utf8_lossy(&output.stdout) | ||
); | ||
} | ||
|
||
// Optionally print the stdout output if you want to see the build logs | ||
println!("{}", String::from_utf8_lossy(&output.stdout)); | ||
|
||
Ok(()) | ||
} | ||
|
||
fn main() { | ||
#[cfg(feature = "webui")] | ||
{ | ||
let webui_dir = Path::new("webui"); | ||
let webui_src_dir = webui_dir.join("src"); | ||
|
||
println!("cargo:rerun-if-changed={}", webui_src_dir.to_str().unwrap()); | ||
|
||
// Run "npm install && npm run build" in the webui directory | ||
for cmd in ["npm install", "npm run build"] { | ||
run_cmd(webui_dir, cmd).unwrap(); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters