Skip to content

Commit

Permalink
refactor: refactor to simplify and improve testability
Browse files Browse the repository at this point in the history
  • Loading branch information
evilrobot-01 committed May 22, 2024
1 parent 0be19a5 commit 87008bc
Show file tree
Hide file tree
Showing 3 changed files with 1,049 additions and 559 deletions.
13 changes: 6 additions & 7 deletions crates/pop-cli/src/commands/up/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,10 @@ impl ZombienetCommand {
let missing: Vec<_> = zombienet
.missing_binaries()
.into_iter()
.flat_map(|b| {
b.sources().map(move |s| match s {
Source::Local { path } => (path.to_str().unwrap(), b, true),
Source::Url { name, .. } => (name.as_str(), b, false),
Source::Git { package, .. } => (package.as_str(), b, false),
})
.filter_map(|b| match &b.source {
Source::Local { .. } => Some((b.name.as_str(), b, true)),
Source::Url { .. } | Source::Git { .. } => Some((b.name.as_str(), b, false)),
Source::None | Source::Artifact => None,
})
.collect();
if missing.len() > 0 {
Expand Down Expand Up @@ -110,12 +108,13 @@ impl ZombienetCommand {
}

// Source binaries
let working_dir = cache.join(".src");
for (_name, binary, _local) in remote {
let multi = multi_progress(format!("📦 Sourcing {}...", binary.name));
let progress = multi.add(cliclack::spinner());
let progress_reporter = ProgressReporter(&progress);
for attempt in (0..=1).rev() {
if let Err(e) = binary.source(&cache, progress_reporter).await {
if let Err(e) = binary.source(&working_dir, progress_reporter).await {
match attempt {
0 => {
progress.error(format!("🚫 Sourcing failed: {e}"));
Expand Down
Loading

0 comments on commit 87008bc

Please sign in to comment.