Refactor into multiple command files #20

Merged
CTO merged 3 commits from refactor/#18 into main 2024-03-08 21:05:21 +00:00
Showing only changes of commit 7b499d7638 - Show all commits

View File

@@ -69,28 +69,32 @@ const command = new Command("commit")
process.exit(0);
}
const changedLines = (
(
await simpleGit().diff(["--numstat", stageAll ? "HEAD" : "--cached"])
).match(/\d+/gm) || []
).reduce((partialSum, num) => partialSum + Number(num), 0);
try {
const changedLines = (
(
await simpleGit().diff(["--numstat", stageAll ? "HEAD" : "--cached"])
).match(/\d+/gm) || []
).reduce((partialSum, num) => partialSum + Number(num), 0);
if (changedLines > 250 && !sudo) {
const proceedCommitting = await confirm({
message:
"You are about to commit changes to more than 250 lines, are you sure you want to proceed?",
initialValue: false,
});
if (changedLines > 250 && !sudo) {
const proceedCommitting = await confirm({
message:
"You are about to commit changes to more than 250 lines, are you sure you want to proceed?",
initialValue: false,
});
if (isCancel(proceedCommitting)) {
cancel("Commit creation cancelled");
process.exit(0);
}
if (!proceedCommitting) {
cancel("Cancelled, please split this commit into smaller ones");
process.exit(0);
if (isCancel(proceedCommitting)) {
cancel("Commit creation cancelled");
process.exit(0);
}
if (!proceedCommitting) {
cancel("Cancelled, please split this commit into smaller ones");
process.exit(0);
}
}
} catch {
note("HEAD hasn't been found, skipping commit line amount check");
}
const type: string | symbol = await select({