Skip to content

Commit 2f328c1

Browse files
committed
Not all projects have a .gitignore
1 parent 070644b commit 2f328c1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/vitest/coverage-provider.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,20 @@ class JsonSchemaCoverageProvider {
112112

113113
// Build coverage maps
114114
for (const root of this.roots) {
115+
const i = ignore();
116+
const gitignorePath = path.resolve(root, ".gitignore");
117+
if (existsSync(gitignorePath)) {
118+
const gitignore = await fs.readFile(gitignorePath, "utf-8");
119+
i.add(gitignore);
120+
}
121+
115122
let includedFiles = await glob(this.include, {
116123
cwd: root,
117124
dot: true,
118125
onlyFiles: true
119126
});
120-
const gitignorePath = path.resolve(root, ".gitignore");
121-
const gitignore = await fs.readFile(gitignorePath, "utf-8");
122-
const files = ignore()
123-
.add(gitignore)
127+
128+
const files = i
124129
.filter(includedFiles)
125130
.map((file) => path.resolve(root, file));
126131

0 commit comments

Comments
 (0)