Skip to content

Commit

Permalink
fix: check environment name before returning not found print (#2198)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruben-arts authored Oct 4, 2024
1 parent 8ba4c4a commit 0317e0a
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,32 +55,27 @@ pub async fn execute(args: Args) -> miette::Result<()> {
let project = Project::load_or_else_discover(args.project_config.manifest_path.as_deref())?
.with_cli_config(args.prefix_update_config.config.clone());

// Extract the passed in environment name.
let environment = project.environment_from_name_or_env_var(args.environment.clone())?;

// Find the environment to run the task in, if any were specified.
let explicit_environment = if environment.is_default() {
None
} else {
Some(environment.clone())
};

// Print all available tasks if no task is provided
if args.task.is_empty() {
command_not_found(
&project,
args.environment
.clone()
.and_then(|env| project.environment_from_name_or_env_var(Some(env)).ok()),
);
command_not_found(&project, explicit_environment);
return Ok(());
}

// Sanity check of prefix location
verify_prefix_location_unchanged(project.default_environment().dir().as_path()).await?;

// Extract the passed in environment name.
let environment = project.environment_from_name_or_env_var(args.environment.clone())?;

let best_platform = environment.best_platform();

// Find the environment to run the task in, if any were specified.
let explicit_environment = if environment.is_default() {
None
} else {
Some(environment)
};

// Verify that the current platform has the required virtual packages for the environment.
if let Some(ref explicit_environment) = explicit_environment {
verify_current_platform_has_required_virtual_packages(explicit_environment)
Expand Down

0 comments on commit 0317e0a

Please sign in to comment.