From cc46af919be9c5b591014b431a18c1571c9cf04f Mon Sep 17 00:00:00 2001 From: DinoscapeProgramming Date: Sun, 10 Aug 2025 18:39:57 +0200 Subject: [PATCH] feat: add Windows support by using shx and pathToFileURL for imports --- bench.js | 3 ++- package.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bench.js b/bench.js index eeb64dd..4ca8224 100644 --- a/bench.js +++ b/bench.js @@ -7,6 +7,7 @@ import colors from "picocolors"; import { readdirSync } from "node:fs"; import { resolve } from "node:path"; import { argv } from "node:process"; +import { pathToFileURL } from "node:url"; const benchmarkType = argv.includes("--theoretical") ? "theoretical" : "applied"; @@ -16,7 +17,7 @@ const benchmarks = readdirSync(resolve("./benchmarks", benchmarkType)).filter( ); console.log(`Running ${benchmarks.length} ${benchmarkType} benchmarks`); for (const file of benchmarks) { - const benchmark = await import(resolve("benchmarks", benchmarkType, file)); + const benchmark = await import(pathToFileURL(resolve("benchmarks", benchmarkType, file))); const obj = benchmark.original; const newObj = benchmark.changed; diff --git a/package.json b/package.json index 7f7e3aa..f001d1e 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "require": "./dist/index.cjs" }, "scripts": { - "build": "tsc --module CommonJS && mv \"dist/index.js\" \"dist/index.cjs\" && mv \"dist/index.d.ts\" \"dist/index.d.cts\" && tsc --module es2020 && prettier -w dist/*", + "build": "tsc --module CommonJS && shx mv \"dist/index.js\" \"dist/index.cjs\" && shx mv \"dist/index.d.ts\" \"dist/index.d.cts\" && tsc --module es2020 && prettier -w dist/*", "test": "npm run build && node --test ./tests/*", "bench": "npm run build && node --expose-gc bench.js", "prepublish": "npm run build" @@ -30,6 +30,7 @@ "mitata": "^1.0.19", "picocolors": "^1.1.1", "prettier": "^3.4.1", + "shx": "^0.4.0", "typescript": "^5.7.2" }, "type": "module",