Skip to content

Commit

Permalink
Enhancement (Code Refactor): Separated out the redundant directory ch…
Browse files Browse the repository at this point in the history
…eck code into a separate function.
  • Loading branch information
Anmol Shukla committed Oct 12, 2019
1 parent d10bc1c commit 9d5d5bb
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 checkIfDirExists = () => {
if (
fs.existsSync(`${process.cwd()}/teachcode-solutions`) ||
fs.existsSync(`${process.cwd()}/config.json`)
Expand All @@ -75,6 +67,22 @@ const initTasks = async () => {
console.log();
process.exit(1);
}
};

/**
* 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();

checkIfDirExists();

console.log();
console.log(
Expand Down

0 comments on commit 9d5d5bb

Please sign in to comment.