Skip to content
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

chore(dev-infra): check git is clean before generating commit #62

Merged
merged 1 commit into from
Mar 16, 2022
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
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