Skip to content

Commit 7b596fe

Browse files
author
Alexander Lisianoi
committed
Fail softer if running global commitplease in an empty/nonexistent git
Closes #84
1 parent cec0dd6 commit 7b596fe

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,20 @@ module.exports = function () {
117117

118118
repo.exec('log', format, committish, function (error, messages) {
119119
if (error) {
120+
if (/Not a git repository/.test(error.message)) {
121+
console.log(error.message)
122+
123+
process.exit(0)
124+
}
125+
126+
if (/does not have any commits yet/.test(error.message)) {
127+
console.log(error.message)
128+
129+
process.exit(0)
130+
}
131+
120132
console.error(error)
133+
121134
process.exit(1)
122135
}
123136

0 commit comments

Comments
 (0)