prettify build.rs a bit
This commit is contained in:
parent
f0c882deb7
commit
6f40465aa0
1 changed files with 30 additions and 1 deletions
|
|
@ -1,7 +1,36 @@
|
|||
use anyhow::Context;
|
||||
use anyhow::{bail, Context};
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
fn run(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")]
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue