@@ -4,12 +4,9 @@ import path from "node:path";
44import coverage from "istanbul-lib-coverage" ;
55import libReport from "istanbul-lib-report" ;
66import reports from "istanbul-reports" ;
7- import ignore from "ignore" ;
8- import { glob } from "tinyglobby" ;
97import { resolve } from "pathe" ;
108import c from "tinyrainbow" ;
119import { coverageConfigDefaults } from "vitest/config" ;
12- import { registerSchema } from "./json-schema-matchers.js" ;
1310import { FileCoverageMapService } from "./file-coverage-map-service.js" ;
1411
1512/**
@@ -45,11 +42,6 @@ class JsonSchemaCoverageProvider {
4542 coverageFilesDirectory = ".json-schema-coverage" ;
4643 coverageService = new FileCoverageMapService ( ".json-schema-coverage/maps" ) ;
4744
48- /** @type string[] */
49- roots = [ ] ;
50-
51- include = [ "**/*.schema.json" , "**/*.schema.yaml" , "**/*.schema.yml" ] ;
52-
5345 /** @type CoverageProvider["initialize"] */
5446 initialize ( ctx ) {
5547 this . ctx = ctx ;
@@ -73,14 +65,8 @@ class JsonSchemaCoverageProvider {
7365 reporter : resolveCoverageReporters ( config . reporter || coverageConfigDefaults . reporter )
7466 } ;
7567
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 ) ;
8470 }
8571
8672 /** @type CoverageProvider["resolveOptions"] */
@@ -109,37 +95,6 @@ class JsonSchemaCoverageProvider {
10995 await this . coverageService . open ( ) ;
11096
11197 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- }
14398 }
14499
145100 /** @type () => Promise<void> */
0 commit comments