Skip to content

Commit

Permalink
chore: minor refactor (facebook#1630)
Browse files Browse the repository at this point in the history
* feat: minor refactor

* Minor fix

* Update init.ts
  • Loading branch information
jamesgeorge007 authored and yangshun committed Jun 30, 2019
1 parent a6736dd commit f4effe4
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions packages/docusaurus/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function hasYarn(): boolean {
}

function isValidGitRepoUrl(gitRepoUrl): boolean {
return gitRepoUrl.startsWith('https://') || gitRepoUrl.startsWith('git@');
return ['https://', 'git@'].some(item => gitRepoUrl.startsWith(item));
}

async function updatePkg(pkgPath: string, obj): Promise<void> {
Expand Down Expand Up @@ -162,12 +162,10 @@ export async function init(
console.log();

// Display the most elegant way to cd.
let cdpath;
if (path.join(process.cwd(), name) === dest) {
cdpath = name;
} else {
cdpath = path.relative(process.cwd(), dest);
}
const cdpath =
path.join(process.cwd(), name) === dest
? name
: path.relative(process.cwd(), name);

console.log();
console.log(`Success! Created ${chalk.cyan(cdpath)}`);
Expand Down

0 comments on commit f4effe4

Please sign in to comment.