mirror of
https://github.com/di-sukharev/opencommit.git
synced 2026-04-20 03:02:51 -04:00
refactor(prepare-commit-msg-hook.ts): simplify conditional statements
The conditional statements in the prepareCommitMessageHook function have been simplified to improve readability. The first conditional statement now checks if there are no staged files and no changed files, and if so, it will output a message and exit the process. The second conditional statement now checks if there are no staged files but there are changed files, and if so, it will add the changed files to the staging area.
This commit is contained in:
@@ -20,12 +20,13 @@ export const prepareCommitMessageHook = async () => {
|
||||
const stagedFiles = await getStagedFiles();
|
||||
const changedFiles = await getChangedFiles();
|
||||
|
||||
if (!stagedFiles && changedFiles) await gitAdd({ files: changedFiles });
|
||||
else {
|
||||
if (!stagedFiles && !changedFiles) {
|
||||
outro('No changes detected, write some code and run `oc` again');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (!stagedFiles && changedFiles) await gitAdd({ files: changedFiles });
|
||||
|
||||
const staged = await getStagedFiles();
|
||||
|
||||
if (!staged) return;
|
||||
|
||||
Reference in New Issue
Block a user