Skip to content

Commit dc9eb6b

Browse files
committed
Ensure that we simply return null results if not in a git dir.
1 parent bb306d2 commit dc9eb6b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ function findRepo(startingPath) {
3232
module.exports = function(gitPath) {
3333
if (!gitPath) { gitPath = findRepo(); }
3434

35-
var headFilePath = path.join(gitPath, 'HEAD');
36-
3735
var result = {
3836
sha: null,
3937
abbreviatedSha: null,
4038
branch: null
4139
}
4240

4341
try {
42+
var headFilePath = path.join(gitPath, 'HEAD');
43+
4444
if (fs.existsSync(headFilePath)) {
4545
var branchSHA;
4646
var headFile = fs.readFileSync(headFilePath, {encoding: 'utf8'});

0 commit comments

Comments
 (0)