Skip to content
Snippets Groups Projects
Commit 248c937d authored by Cédric Moreau's avatar Cédric Moreau
Browse files

feat: debug xtask

parent fb00d593
No related branches found
No related tags found
No related merge requests found
......@@ -14,7 +14,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use anyhow::Result;
use std::process::{Command, Output};
use std::process::{Command, Output, Stdio};
use structopt::StructOpt;
use version_compare::Version;
......@@ -101,7 +101,7 @@ fn exec_and_get_stdout(command: &mut Command) -> Result<String> {
}
fn exec_should_success(command: &mut Command) -> Result<()> {
if !command.status()?.success() {
if !command.stdout(Stdio::piped()).status()?.success() {
std::process::exit(1);
} else {
Ok(())
......@@ -109,27 +109,33 @@ fn exec_should_success(command: &mut Command) -> Result<()> {
}
fn build(skip_npm: bool, production: bool) -> Result<()> {
println!("skip npm ? {}", skip_npm);
if !skip_npm {
exec_should_success(Command::new("npm").args(&["add", "duniter-ui"]))?;
println!("npm add duniter-ui");
exec_should_success(Command::new("C:\\Program Files\\nodejs\\npm.cmd").args(&["add", "duniter-ui"]))?;
println!("npm ci");
exec_should_success(
Command::new("npm")
.env("NEON_BUILD_RELEASE", "true")
Command::new("C:\\Program Files\\nodejs\\npm.cmd")
// .env("PATH", "true")
.arg("ci"),
)?;
if production {
exec_should_success(Command::new("npm").args(&["prune", "--production"]))?;
println!("npm prune --production");
exec_should_success(Command::new("C:\\Program Files\\nodejs\\npm.cmd").args(&["prune", "--production"]))?;
}
}
println!("Build duniter-cli …");
exec_should_success(Command::new("cargo").args(&["build", "--release"]))?;
std::fs::copy("target/release/duniter", "bin/duniter")?;
println!("Copy final binary to bin/duniter");
std::fs::copy("target/release/duniter.exe", "bin/duniter")?;
println!("Build success.");
Ok(())
}
fn test(skip_npm: bool) -> Result<()> {
exec_should_success(Command::new("cargo").args(&["test", "--all"]))?;
if !skip_npm {
exec_should_success(Command::new("npm").arg("test"))?;
exec_should_success(Command::new("C:\\Program Files\\nodejs\\npm.cmd").arg("test"))?;
}
Ok(())
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment