From 50e5d942f72a7b756c36fdc57b7899ad8b6ff7c7 Mon Sep 17 00:00:00 2001 From: maciektr Date: Fri, 17 Nov 2023 13:53:05 +0100 Subject: [PATCH] Move validation before usage in build-external glob selectors (#914) --- scarb/src/compiler/compilers/starknet_contract.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scarb/src/compiler/compilers/starknet_contract.rs b/scarb/src/compiler/compilers/starknet_contract.rs index 06b13f5be..00f8f3ad7 100644 --- a/scarb/src/compiler/compilers/starknet_contract.rs +++ b/scarb/src/compiler/compilers/starknet_contract.rs @@ -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); @@ -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()))