Skip to content

Commit

Permalink
Indicate if the cwd doesn't have config files (#2985)
Browse files Browse the repository at this point in the history
### Description

This PR adds a slightly better error message if there is no `./configs`
folder for the CLI invocation
  • Loading branch information
nambrot authored Nov 28, 2023
1 parent 750303a commit 3163475
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions typescript/cli/src/utils/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down

0 comments on commit 3163475

Please sign in to comment.