Skip to content

Commit

Permalink
fix(bug): test if repo has changes before executing commit
Browse files Browse the repository at this point in the history
  • Loading branch information
unjust committed Mar 24, 2023
1 parent e4b3bc8 commit 9c33a79
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scripts/create-cohort-project.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,11 @@ const initRepo = async (repoDir, opts) => {

console.log('Initializing repo...');
await exec('git init', { cwd: repoDir });
await exec('git add .', { cwd: repoDir });
await exec('git commit -m "chore(init): Adds project files from curriculum"', { cwd: repoDir });
const { stdout: hasChanges } = await exec('git status --porcelain', { cwd: repoDir });
if (!!hasChanges) {
await exec('git add .', { cwd: repoDir });
await exec('git commit -m "chore(init): Adds project files from curriculum"', { cwd: repoDir });
}
await exec('git branch -M main', { cwd: repoDir });
};

Expand Down

0 comments on commit 9c33a79

Please sign in to comment.