@@ -4,12 +4,9 @@ import path from "node:path";
4
4
import coverage from "istanbul-lib-coverage" ;
5
5
import libReport from "istanbul-lib-report" ;
6
6
import reports from "istanbul-reports" ;
7
- import ignore from "ignore" ;
8
- import { glob } from "tinyglobby" ;
9
7
import { resolve } from "pathe" ;
10
8
import c from "tinyrainbow" ;
11
9
import { coverageConfigDefaults } from "vitest/config" ;
12
- import { registerSchema } from "./json-schema-matchers.js" ;
13
10
import { FileCoverageMapService } from "./file-coverage-map-service.js" ;
14
11
15
12
/**
@@ -45,11 +42,6 @@ class JsonSchemaCoverageProvider {
45
42
coverageFilesDirectory = ".json-schema-coverage" ;
46
43
coverageService = new FileCoverageMapService ( ".json-schema-coverage/maps" ) ;
47
44
48
- /** @type string[] */
49
- roots = [ ] ;
50
-
51
- include = [ "**/*.schema.json" , "**/*.schema.yaml" , "**/*.schema.yml" ] ;
52
-
53
45
/** @type CoverageProvider["initialize"] */
54
46
initialize ( ctx ) {
55
47
this . ctx = ctx ;
@@ -73,14 +65,8 @@ class JsonSchemaCoverageProvider {
73
65
reporter : resolveCoverageReporters ( config . reporter || coverageConfigDefaults . reporter )
74
66
} ;
75
67
76
- // If --project filter is set pick only roots of resolved projects
77
- this . roots = ctx . config . project ?. length
78
- ? [ ...new Set ( ctx . projects . map ( ( project ) => project . config . root ) ) ]
79
- : [ ctx . config . root ] ;
80
-
81
- if ( "include" in config ) {
82
- this . include = config . include ;
83
- }
68
+ const buildScriptPath = path . resolve ( import . meta. dirname , "./build-coverage-maps.js" ) ;
69
+ /** @type string[] */ ( ctx . config . globalSetup ) . push ( buildScriptPath ) ;
84
70
}
85
71
86
72
/** @type CoverageProvider["resolveOptions"] */
@@ -109,37 +95,6 @@ class JsonSchemaCoverageProvider {
109
95
await this . coverageService . open ( ) ;
110
96
111
97
await fs . mkdir ( this . coverageFilesDirectory , { recursive : true } ) ;
112
-
113
- // Build coverage maps
114
- 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
-
122
- let includedFiles = await glob ( this . include , {
123
- cwd : root ,
124
- dot : true ,
125
- onlyFiles : true
126
- } ) ;
127
-
128
- const files = i
129
- . filter ( includedFiles )
130
- . map ( ( file ) => path . resolve ( root , file ) ) ;
131
-
132
- for ( const schemaPath of files ) {
133
- try {
134
- await registerSchema ( schemaPath ) ;
135
- } catch ( _error ) {
136
- }
137
- }
138
-
139
- for ( const file of files ) {
140
- await this . coverageService . addFromFile ( file ) ;
141
- }
142
- }
143
98
}
144
99
145
100
/** @type () => Promise<void> */
0 commit comments