Skip to content

Commit

Permalink
Separated out the redundant directory check code into a separate func…
Browse files Browse the repository at this point in the history
…tion.
  • Loading branch information
Anmol Shukla committed Oct 8, 2019
1 parent d10bc1c commit 5e972c1
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,10 @@ const showInstructions = kickStart => {
};

/**
* Initialize all the tasks
*
* @returns {Promise<void>}
* Checks if there already is a directory called 'teachcode-solutions' in the present working directory
* and errors out if that is the case.
*/

const initTasks = async () => {
await showBanner(
'teachcode',
` Learn to code effectively ${`\t`.repeat(4)} Powered by MadHacks`,
);
console.log();

const checkRedundantDirectory = () => {
if (
fs.existsSync(`${process.cwd()}/teachcode-solutions`) ||
fs.existsSync(`${process.cwd()}/config.json`)
Expand Down Expand Up @@ -88,6 +80,22 @@ const initTasks = async () => {
)}`,
),
);
};

/**
* Initialize all the tasks
*
* @returns {Promise<void>}
*/

const initTasks = async () => {
await showBanner(
'teachcode',
` Learn to code effectively ${`\t`.repeat(4)} Powered by MadHacks`,
);
console.log();

checkRedundantDirectory();

const { learningTrackOfChoice } = await inquirer.prompt([
{
Expand Down

0 comments on commit 5e972c1

Please sign in to comment.