From 70349d12484cc7694ca83ed92d2393a1acfb838b Mon Sep 17 00:00:00 2001 From: MURANGWA Pacifique Date: Thu, 23 Nov 2023 11:18:02 +0200 Subject: [PATCH] fix: undefined directory with profile command --- src/commands/profile.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/commands/profile.ts b/src/commands/profile.ts index 4a2aca4..ccb040d 100644 --- a/src/commands/profile.ts +++ b/src/commands/profile.ts @@ -4,7 +4,7 @@ import inquirer from 'inquirer'; import chalk from 'chalk'; import { Log } from '../lib/helper'; -const profileCommand = (folderDir: string) => { +const profileCommand = async (folderDir: string) => { const lepperDirectory = path.join(process.cwd(), '.lepper'); const infoFilePath = path.join(lepperDirectory, '_info.json'); @@ -21,6 +21,21 @@ const profileCommand = (folderDir: string) => { ? JSON.parse(fs.readFileSync(infoFilePath, 'utf-8')) : {}; + if (folderDir == undefined) { + // If no folder is provided, ask the user to select a folder + const answers = await inquirer.prompt([ + { + type: 'input', + name: 'directory', + message: chalk.cyan(`Please specify the directory: `), + }, + ]); + answers.directory.length !== 0 + ? (folderDir = await answers.directory) + : console.error(chalk.red.bold("Directory can't be empty")), + process.exit(1); + } + // Prompt the user for a description inquirer .prompt([