Skip to content

Commit 82ea59d

Browse files
fix: module path resolution on Windows (#42)
1 parent 35a9a6d commit 82ea59d

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

‎src/Test/Spec/Discovery.js‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import path from 'path'
22
import fs from 'fs'
3-
import { fileURLToPath } from 'url'
3+
import { fileURLToPath, pathToFileURL } from 'url'
44

55
const __filename = fileURLToPath(import.meta.url)
66
const __dirname = path.dirname(__filename)
@@ -19,9 +19,8 @@ export function getSpecs(pattern) {
1919
.readdirSync(path.join(__dirname, '..'))
2020
.filter(directory => regex.test(directory))
2121
.map(name => {
22-
const fullPath = __onWindows
23-
? path.join('file://', __dirname, '..', name, 'index.js')
24-
: path.join(__dirname, '..', name, 'index.js')
22+
const filePath = path.join(__dirname, '..', name, 'index.js')
23+
const fullPath = pathToFileURL(filePath, { "windows": __onWindows }).href
2524
return import(fullPath).then(module =>
2625
module && typeof module.spec !== 'undefined' ? { name, spec: module.spec } : null
2726
)

0 commit comments

Comments
 (0)