Skip to content

fix: issue where starter kit can only be run once #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 8, 2023
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