Skip to content

Commit

Permalink
chore(dev-infra): check git is clean before generating commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackbaud-SteveBrush committed Mar 15, 2022
1 parent d0a6100 commit 48d171a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions scripts/dev-pristine.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import inquirer from 'inquirer';

import { addAll, fetchAll, getCurrentBranch } from './utils/git-utils';
import {
addAll,
fetchAll,
getCurrentBranch,
isGitClean,
} from './utils/git-utils';
import { getCommandOutput, runCommand } from './utils/spawn';

async function promptCommit() {
Expand Down Expand Up @@ -76,10 +81,17 @@ async function devPristine() {
throw new Error("This command may not be executed on the 'main' branch.");
}

// Ensure local git is clean.
if (!(await isGitClean())) {
throw new Error(
'Uncommitted changes detected. Stash or commit the changes and try again.'
);
}

await promptCommit();
await promptPush();
} catch (err) {
console.error(err);
console.error(`[dev:pristine error] ${err.message}\n`);
process.exit(1);
}
}
Expand Down

0 comments on commit 48d171a

Please sign in to comment.