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
pull/2998/head
Nam Chu Hoai 1 year ago committed by GitHub
parent 750303a30f
commit 3163475ab2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      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: [

Loading…
Cancel
Save