@@ -6,14 +6,15 @@ import { findUp } from 'find-up'
66import { mkdtemp , rm , readFile } from 'node:fs/promises'
77import { createWriteStream } from 'node:fs'
88import { finished } from 'node:stream/promises'
9- import { join , relative } from 'node:path'
9+ import { join , relative , resolve } from 'node:path'
1010import posix from 'node:path/posix'
1111import runWithTypeScript from './lib/run.js'
1212import githubReporter from '@reporters/github'
1313import { Report } from 'c8'
1414import { checkCoverages } from 'c8/lib/commands/check-coverage.js'
1515import os from 'node:os'
1616import { execa } from 'execa'
17+ import { pathToFileURL } from 'node:url'
1718
1819/* c8 ignore next 4 */
1920process . on ( 'unhandledRejection' , ( err ) => {
@@ -120,7 +121,12 @@ try {
120121 } else {
121122 try {
122123 // Try to load a custom reporter from a file relative to the process.
123- const modPath = join ( process . cwd ( ) , name . replace ( / ^ [ ' " ] / , '' ) . replace ( / [ ' " ] $ / , '' ) )
124+ let modPath = resolve ( join ( process . cwd ( ) , name . replace ( / ^ [ ' " ] / , '' ) . replace ( / [ ' " ] $ / , '' ) ) )
125+ if ( process . platform === 'win32' ) {
126+ // On Windows, absolute paths must be valid file:// URLs
127+ modPath = pathToFileURL ( modPath ) . href
128+ }
129+
124130 Ctor = await import ( modPath ) . then ( ( m ) => m . default || m )
125131 } catch {
126132 // Fallback to trying to load the reporter from node_modules resolution.
0 commit comments