Skip to content

Commit

Permalink
fails on the first error + escape shell command
Browse files Browse the repository at this point in the history
  • Loading branch information
kaplanelad committed Oct 15, 2024
1 parent b2b1d3a commit 9d7eb8b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
1 change: 1 addition & 0 deletions xtask/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ thiserror = "1"
tabled = "0.14.0"
colored = "2.1.0"
crazy-train = "0.1.0"
shell-escape = "0.1.5"

[dev-dependencies]
17 changes: 4 additions & 13 deletions xtask/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use clap::{
ArgAction::{SetFalse, SetTrue},
Parser, Subcommand,
};
use colored::Colorize;
use std::env;
use xtask::fuzzy_steps;

Expand Down Expand Up @@ -123,7 +122,6 @@ fn main() -> eyre::Result<()> {
.collect();

results.sort_by(|a, b| a.error.is_some().cmp(&b.error.is_some()));
let mut has_error = false;

println!();
println!("====================================");
Expand All @@ -132,21 +130,14 @@ fn main() -> eyre::Result<()> {

for result in results {
if let Some(err) = result.error {
has_error = true;
println!(
"{}",
format!("seed {}: error\n\n {}\n", result.seed, err).red()
);
println!("seed {}: error\n\n {}\n", result.seed, err);
xtask::CmdExit::error_with_message("failed").exit();
} else {
println!("{}", format!("seed {}: passed", result.seed).green());
println!("seed {}: passed", result.seed);
}
}

if has_error {
xtask::CmdExit::error_with_message("failed")
} else {
xtask::CmdExit::ok()
}
xtask::CmdExit::ok()
}
};

Expand Down
4 changes: 3 additions & 1 deletion xtask/src/fuzzy_steps/generate_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ impl step::StepTrait for GenerateProjectStep {

fn plan(&self, _randomizer: &Randomizer) -> crazy_train::Result<step::Plan> {
// TODO:: --template and --assets should be random also
let command = format!("loco new --name '{}' --template saas --db sqlite --bg async --assets serverside --path {}", self.project_name,self.location.display());
let escaped_project_name =
shell_escape::escape(self.project_name.clone().into()).to_string();
let command = format!("loco new --name {} --template saas --db sqlite --bg async --assets serverside --path {}", escaped_project_name,self.location.display());

Ok(step::Plan {
id: std::any::type_name::<Self>().to_string(),
Expand Down

0 comments on commit 9d7eb8b

Please sign in to comment.