Skip to content

Commit

Permalink
Move validation before usage in build-external glob selectors (#914)
Browse files Browse the repository at this point in the history
  • Loading branch information
maciektr authored Nov 17, 2023
1 parent e55953b commit 50e5d94
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions scarb/src/compiler/compilers/starknet_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,14 @@ impl Compiler for StarknetContractCompiler {
);
}

if let Some(external_contracts) = props.build_external_contracts.clone() {
for path in external_contracts.iter() {
ensure!(path.0.matches(GLOB_PATH_SELECTOR).count() <= 1,
"external contract path {} has multiple global path selectors, only one '*' selector is allowed",
path.0);
}
}

let target_dir = unit.target_dir(ws);

let compiler_config = build_compiler_config(&unit, ws);
Expand All @@ -215,12 +223,6 @@ impl Compiler for StarknetContractCompiler {
props.build_external_contracts.clone(),
)?;

if let Some(external_contracts) = props.build_external_contracts.clone() {
for path in external_contracts.iter() {
ensure!(path.0.matches(GLOB_PATH_SELECTOR).count() <= 1, format!("external contract path {} has multiple global path selectors, only one '*' selector is allowed", path.0));
}
}

let contract_paths = contracts
.iter()
.map(|decl| decl.module_id().full_path(db.upcast_mut()))
Expand Down

0 comments on commit 50e5d94

Please sign in to comment.