Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena committed Dec 15, 2021
1 parent ded4c3d commit 2ddfe2a
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions packages/create-docusaurus/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,11 @@ ${chalk.cyan('Creating new Docusaurus project...')}
}

const pkgManager = useYarn ? 'yarn' : 'npm';
let isInstallSuccessful = true;
// Display the most elegant way to cd.
const cdpath =
path.join(process.cwd(), name) === dest
? name
: path.relative(process.cwd(), name);
if (!cliOptions.skipInstall) {
console.log(`Installing dependencies with ${chalk.cyan(pkgManager)}...`);
if (
Expand All @@ -284,17 +288,16 @@ ${chalk.cyan('Creating new Docusaurus project...')}
},
).code !== 0
) {
isInstallSuccessful = false;
console.error(chalk.red('Dependency installation failed.'));
console.log(`The site directory has already been created, and you can retry by typing:
${chalk.cyan('cd')} ${cdpath}
${chalk.cyan(`${pkgManager} install`)}`);
process.exit(0);
}
}
// Display the most elegant way to cd.
const cdpath =
path.join(process.cwd(), name) === dest
? name
: path.relative(process.cwd(), name);

if (isInstallSuccessful) {
console.log(`
console.log(`
Successfully created "${chalk.cyan(cdpath)}".
Inside that directory, you can run several commands:
Expand All @@ -317,11 +320,4 @@ We recommend that you begin by typing:
Happy building awesome websites!
`);
} else {
console.error(chalk.red('Dependency installation failed.'));
console.log(`The site directory has been created, and you can retry by typing:
${chalk.cyan('cd')} ${cdpath}
${chalk.cyan(`${pkgManager} install`)}`);
}
}

0 comments on commit 2ddfe2a

Please sign in to comment.