From 269912ad93ff55369b1460de71973e96c9e31b74 Mon Sep 17 00:00:00 2001 From: Thadeu Cotts Date: Thu, 26 Nov 2020 16:12:02 -0300 Subject: [PATCH] [refactor] [s]: update prompt validate --- packages/create-portal-app/index.js | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/packages/create-portal-app/index.js b/packages/create-portal-app/index.js index cc2c4c43..dbd513d9 100755 --- a/packages/create-portal-app/index.js +++ b/packages/create-portal-app/index.js @@ -19,28 +19,15 @@ let projectPath = ""; program .name(package.name) .version(package.version) - /** - * TODO - * Add Options - * Add Example Options - * Add templates - */ .arguments("[dir]") .usage(`${chalk.yellow("[dir]")}`) .description({ dir: "Directory to be used on install Portal.js", }) .action((name) => (projectPath = name)) - .option('--use-npm') - .allowUnknownOption() + .option("--use-npm") .parse(process.argv); -// print a fancy Portal.js in the terminal -console.log( - chalk.yellow( - figlet.textSync('Portal.Js', {horizontalLayout: 'full'}) - ) -); /** * Method to ask a custon name if was not passed as parameter * returns the value passed from terminal input @@ -52,8 +39,15 @@ async function promptPath() { message: "Choose a name to your project", initial: "", validate: (name) => { - //TODO Method to validate valid path name - return true; + projectPath = name + if(isPathInUse(projectPath)){ + return `${chalk.yellow( + "Path " + + chalk.redBright(projectPath) + + " is already in use and is not empty." + )}` + } + return true }, }); }