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