From 3163475ab2d8d6bb1fa52467062b417dbd7a7317 Mon Sep 17 00:00:00 2001 From: Nam Chu Hoai Date: Tue, 28 Nov 2023 18:08:55 -0500 Subject: [PATCH] Indicate if the cwd doesn't have config files (#2985) ### Description This PR adds a slightly better error message if there is no `./configs` folder for the CLI invocation --- typescript/cli/src/utils/files.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/typescript/cli/src/utils/files.ts b/typescript/cli/src/utils/files.ts index aa0cfd65f5..afed211ffa 100644 --- a/typescript/cli/src/utils/files.ts +++ b/typescript/cli/src/utils/files.ts @@ -163,11 +163,16 @@ export async function runFileSelectionStep( description: string, pattern?: string, ) { + const noFilesErrorMessage = `No "${description}" found in ${folderPath}. Please confirm the path for "${description}". By default, the CLI writes to folders relative to where its run.`; + if (!fs.existsSync(folderPath)) throw new Error(noFilesErrorMessage); + let filenames = fs.readdirSync(folderPath); if (pattern) { filenames = filenames.filter((f) => f.includes(pattern)); } + if (filenames.length === 0) throw new Error(noFilesErrorMessage); + let filename = (await select({ message: `Select ${description} file`, choices: [