Skip to content

Commit b574bd0

Browse files
committed
fix: make gitPath value type predictable
1 parent ef8778a commit b574bd0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/gitinfo.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ type TypeConfig = {
1515
};
1616

1717
export default (config: TypeConfig = {}): Object => {
18-
19-
config.gitPath = config.gitPath || __dirname;
20-
let gitPath: string;
18+
let gitPath: string|null = null;
2119

2220
const gitinfo = {};
2321

@@ -127,14 +125,16 @@ export default (config: TypeConfig = {}): Object => {
127125
return parseINI(gitPath + '/config');
128126
};
129127

128+
config.gitPath = config.gitPath || __dirname;
129+
130130
if (isGitDirectory(config.gitPath)) {
131131
gitPath = config.gitPath;
132132
} else {
133133
gitPath = gitPath(config.gitPath);
134134
}
135135

136136
/* istanbul ignore next */
137-
if (!gitPath) {
137+
if (gitPath === null) {
138138
throw new Error('config.gitPath is not a descendant of .git/ director.');
139139
}
140140

0 commit comments

Comments
 (0)