Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ const editFiles = async projectName => {
file.set('name', projectName);
file.save();

fs.rename(
`${__dirname}/starter-kit/gitignore`,
`${__dirname}/starter-kit/.gitignore`,
function (err) {
if (err) throw err;
}
);
if (fs.existsSync(`${__dirname}/starter-kit/gitignore`)) {
fs.rename(
`${__dirname}/starter-kit/gitignore`,
`${__dirname}/starter-kit/.gitignore`,
function (err) {
if (err) throw err;
}
);
}
};

const checkDirectory = async () => {
Expand All @@ -65,7 +67,13 @@ const checkDirectory = async () => {
}
};

const successText = projectName => {
const checkProjectName = async (projectPath) => {
if (fs.existsSync(projectPath)) {
throw `ERROR: Project already exists in directory:: ${projectPath}`;
}
};

const successText = (projectName) => {
const successText = `Success! Created ${chalk.cyan(
projectName
)} at ${chalk.cyan(CURR_DIR)}
Expand Down Expand Up @@ -93,6 +101,8 @@ const run = async () => {

const starterKitPath = `${__dirname}/starter-kit/`;

await checkProjectName(`${CURR_DIR}/${projectName}`);

await editFiles(projectName);

await asyncMkdir(`${CURR_DIR}/${projectName}`);
Expand Down