Run npm install as part of build.rs too
This commit is contained in:
parent
2c71cc1dbb
commit
b2c241c3d8
2 changed files with 29 additions and 21 deletions
6
.github/workflows/test.yml
vendored
6
.github/workflows/test.yml
vendored
|
|
@ -21,9 +21,6 @@ jobs:
|
||||||
rustup toolchain install ${{ matrix.rust_version }}
|
rustup toolchain install ${{ matrix.rust_version }}
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- run: rustup override set ${{ matrix.rust_version }}
|
- run: rustup override set ${{ matrix.rust_version }}
|
||||||
- name: npm install (librqbit/webui)
|
|
||||||
working-directory: crates/librqbit/webui
|
|
||||||
run: npm install
|
|
||||||
- name: cargo check
|
- name: cargo check
|
||||||
run: cargo check
|
run: cargo check
|
||||||
test:
|
test:
|
||||||
|
|
@ -32,8 +29,5 @@ jobs:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- run: rustup toolchain install stable --profile minimal
|
- run: rustup toolchain install stable --profile minimal
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
- name: npm install (librqbit/webui)
|
|
||||||
working-directory: crates/librqbit/webui
|
|
||||||
run: npm install
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: cargo test
|
run: cargo test
|
||||||
|
|
|
||||||
|
|
@ -9,22 +9,36 @@ fn main() {
|
||||||
|
|
||||||
println!("cargo:rerun-if-changed={}", webui_src_dir.to_str().unwrap());
|
println!("cargo:rerun-if-changed={}", webui_src_dir.to_str().unwrap());
|
||||||
|
|
||||||
// Run "npm run build" in the webui directory
|
// Run "npm install && npm run build" in the webui directory
|
||||||
let output = Command::new("npm")
|
for (cmd, args) in [
|
||||||
.arg("run")
|
("npm", ["install"].as_slice()),
|
||||||
.arg("build")
|
("npm", ["run", "build"].as_slice()),
|
||||||
.current_dir(webui_dir)
|
] {
|
||||||
.output()
|
// Run "npm install" in the webui directory
|
||||||
.expect("Failed to execute npm run build");
|
let output = Command::new(cmd)
|
||||||
|
.args(args)
|
||||||
|
.current_dir(webui_dir)
|
||||||
|
.output()
|
||||||
|
.unwrap_or_else(|_| {
|
||||||
|
panic!(
|
||||||
|
"Failed to execute {} {} in {:?}",
|
||||||
|
cmd,
|
||||||
|
args.join(" "),
|
||||||
|
webui_dir
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
panic!(
|
panic!(
|
||||||
"npm run build failed with output: {}",
|
"{} {} failed with output: {}",
|
||||||
String::from_utf8_lossy(&output.stderr)
|
cmd,
|
||||||
);
|
args.join(" "),
|
||||||
|
String::from_utf8_lossy(&output.stderr)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Optionally print the stdout output if you want to see the build logs
|
||||||
|
println!("{}", 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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue