From ad25f865a12089bb073c9d974e41c314202e4d0c Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Mon, 25 Mar 2024 14:51:13 +0100 Subject: [PATCH] feat: skip selecting foundations if repo only has a single one closes #278 --- src/cli/commandOptionsConventions.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/cli/commandOptionsConventions.ts b/src/cli/commandOptionsConventions.ts index 484c388..ac883ec 100644 --- a/src/cli/commandOptionsConventions.ts +++ b/src/cli/commandOptionsConventions.ts @@ -12,12 +12,20 @@ export async function getCurrentWorkingFoundation( logger: Logger, repo: CollieRepository, ): Promise { + // user explicitly set the foundation to use if (foundation) { return foundation; - } else { - const config = new CollieConfig(repo, logger); + } - return config.getProperty("foundation") || - (await InteractivePrompts.selectFoundation(repo, logger)); + // the repo only contains a single foundation anyway, no need to select one + const foundations = await repo.listFoundations(); + if (foundations.length === 1) { + return foundations[0]; } + + // check if a foundation was set in config, otherwise prompt interactively + const config = new CollieConfig(repo, logger); + + return config.getProperty("foundation") || + (await InteractivePrompts.selectFoundation(repo, logger)); }