Skip to content

Commit 8000e1a

Browse files
authored
lazily configure the warg client, only if a registry package is being used (#110)
Fix for issue #109
1 parent 02779f4 commit 8000e1a

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

src/commands/plug.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,17 @@ impl PlugCommand {
9999
let mut graph = CompositionGraph::new();
100100

101101
#[cfg(feature = "registry")]
102-
let client = FileSystemClient::new_with_default_config(self.registry.as_deref()).ok();
102+
let mut client = None;
103103

104104
let socket_path = match &self.socket {
105105
#[cfg(feature = "registry")]
106106
PackageRef::RegistryPackage((name, version)) => {
107-
let client = client.as_ref().ok_or_else(|| {
107+
if client.is_none() {
108+
client = Some(FileSystemClient::new_with_default_config(
109+
self.registry.as_deref(),
110+
));
111+
}
112+
let client = client.as_ref().unwrap().as_ref().map_err(|_| {
108113
anyhow::anyhow!(
109114
"Warg registry is not configured. Package `{name}` was not found."
110115
)
@@ -170,7 +175,12 @@ impl PlugCommand {
170175
let (mut name, path) = match plug_ref {
171176
#[cfg(feature = "registry")]
172177
PackageRef::RegistryPackage((name, version)) => {
173-
let client = client.as_ref().ok_or_else(|| {
178+
if client.is_none() {
179+
client = Some(FileSystemClient::new_with_default_config(
180+
self.registry.as_deref(),
181+
));
182+
}
183+
let client = client.as_ref().unwrap().as_ref().map_err(|_| {
174184
anyhow::anyhow!(
175185
"Warg registry is not configured. Package `{name}` was not found."
176186
)

0 commit comments

Comments
 (0)