Skip to content

Commit 177755a

Browse files
committed
Fixes for running on windows
1 parent ea36d45 commit 177755a

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

src/coverage-map-service.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { readFile } from "node:fs/promises";
22
import { extname } from "node:path";
3+
import { pathToFileURL } from "node:url";
34
import { compile, getKeyword, getSchema } from "@hyperjump/json-schema/experimental";
45
import { jrefTypeOf, Reference } from "@hyperjump/browser/jref";
56
import * as JsonPointer from "@hyperjump/json-pointer";
@@ -40,7 +41,8 @@ export class CoverageMapService {
4041

4142
/** @type (schemaPath: string) => Promise<string> */
4243
async addFromFile(schemaPath) {
43-
const schema = await getSchema(schemaPath);
44+
const schemaUri = pathToFileURL(schemaPath).toString();
45+
const schema = await getSchema(schemaUri);
4446
const compiledSchema = await compile(schema);
4547
const tree = await this.#parseToAst(schemaPath);
4648

src/vitest/build-coverage-maps.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { existsSync } from "node:fs";
22
import { readFile } from "node:fs/promises";
3-
import { resolve } from "node:path";
3+
import { join, resolve } from "node:path";
44
import { glob } from "tinyglobby";
55
import ignore from "ignore";
66
import { registerSchema } from "./json-schema-matchers.js";
@@ -14,7 +14,7 @@ import { FileCoverageMapService } from "./file-coverage-map-service.js";
1414
export const setup = async (projects) => {
1515
const config = projects.vitest.config;
1616

17-
const coverageService = new FileCoverageMapService(".json-schema-coverage/maps");
17+
const coverageService = new FileCoverageMapService(join(".json-schema-coverage", "maps"));
1818

1919
// If --project filter is set pick only roots of resolved projects
2020
const roots = config.project?.length

src/vitest/coverage-provider.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class JsonSchemaCoverageProvider {
4040
globCache = new Map();
4141

4242
coverageFilesDirectory = ".json-schema-coverage";
43-
coverageService = new FileCoverageMapService(".json-schema-coverage/maps");
43+
coverageService = new FileCoverageMapService(path.join(".json-schema-coverage", "maps"));
4444

4545
/** @type CoverageProvider["initialize"] */
4646
initialize(ctx) {
@@ -65,7 +65,7 @@ class JsonSchemaCoverageProvider {
6565
reporter: resolveCoverageReporters(config.reporter || coverageConfigDefaults.reporter)
6666
};
6767

68-
const buildScriptPath = path.resolve(import.meta.dirname, "./build-coverage-maps.js");
68+
const buildScriptPath = path.resolve(import.meta.dirname, "build-coverage-maps.js");
6969
/** @type string[] */ (ctx.config.globalSetup).push(buildScriptPath);
7070
}
7171

src/vitest/json-schema-matchers.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { randomUUID } from "node:crypto";
22
import { existsSync } from "node:fs";
33
import { readFile, writeFile } from "node:fs/promises";
4-
import { extname } from "node:path";
4+
import { extname, join } from "node:path";
55
import { pathToFileURL } from "node:url";
66
import { registerSchema as register, unregisterSchema as unregister, validate } from "./json-schema.js";
77
import { getKeywordId, getKeywordName, BASIC } from "@hyperjump/json-schema/experimental";
@@ -16,7 +16,7 @@ import { toAbsoluteIri } from "@hyperjump/uri";
1616
*/
1717

1818
const coverageFilesDirectory = ".json-schema-coverage";
19-
const coverageMapsDirectory = ".json-schema-coverage/maps";
19+
const coverageMapsDirectory = join(".json-schema-coverage", "maps");
2020

2121
/** @type FileCoverageMapService */
2222
let coverageService;
@@ -41,7 +41,7 @@ export const matchJsonSchema = async (instance, uriOrSchema) => {
4141
plugins: [testCoveragePlugin]
4242
});
4343

44-
const coverageMapPath = `${coverageFilesDirectory}/${randomUUID()}.json`;
44+
const coverageMapPath = join(coverageFilesDirectory, `${randomUUID()}.json`);
4545
const coverageMapJson = JSON.stringify(testCoveragePlugin.coverage);
4646
await writeFile(coverageMapPath, coverageMapJson);
4747
} else {

0 commit comments

Comments
 (0)