Skip to content

Commit cb140b4

Browse files
committed
✨ tweak: add git repository check.
1 parent 4f6b75a commit cb140b4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

source/app.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import React from 'react';
22
import {Text, Newline} from 'ink';
33
import BigText from 'ink-big-text';
44
import Gradient from 'ink-gradient';
5+
import isGit from 'is-git-repository';
6+
import isCommitterSet from './utils/errors.js';
57
import info from './utils/info.js';
68
import askForCommitMessage from './utils/commit.js';
79
import { getOpenAIKey, setOpenAIKey, deleteOPenAIKey } from './utils/api.js';
@@ -19,7 +21,13 @@ export default function App({flags}) {
1921
console.log('Run `magicc --setopenai=<api-key>` to save your API key and try again.');
2022
} else {
2123
console.log('You have an OpenAI API key, you can now generate a commit message.');
22-
askForCommitMessage();
24+
const gitCheck = isGit();
25+
const committerCheck = isCommitterSet();
26+
if (gitCheck && committerCheck) {
27+
askForCommitMessage();
28+
} else {
29+
console.log('This is not a git repository.');
30+
}
2331
}
2432
return (
2533
<>

0 commit comments

Comments
 (0)