Skip to content

Commit

Permalink
fix: windows reporter reference (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
dancastillo authored Oct 11, 2024
1 parent 339c691 commit f763f88
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions borp.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import { findUp } from 'find-up'
import { mkdtemp, rm, readFile } from 'node:fs/promises'
import { createWriteStream } from 'node:fs'
import { finished } from 'node:stream/promises'
import { join, relative } from 'node:path'
import { join, relative, resolve } from 'node:path'
import posix from 'node:path/posix'
import runWithTypeScript from './lib/run.js'
import githubReporter from '@reporters/github'
import { Report } from 'c8'
import { checkCoverages } from 'c8/lib/commands/check-coverage.js'
import os from 'node:os'
import { execa } from 'execa'
import { pathToFileURL } from 'node:url'

/* c8 ignore next 4 */
process.on('unhandledRejection', (err) => {
Expand Down Expand Up @@ -120,7 +121,12 @@ try {
} else {
try {
// Try to load a custom reporter from a file relative to the process.
const modPath = join(process.cwd(), name.replace(/^['"]/, '').replace(/['"]$/, ''))
let modPath = resolve(join(process.cwd(), name.replace(/^['"]/, '').replace(/['"]$/, '')))
if (process.platform === 'win32') {
// On Windows, absolute paths must be valid file:// URLs
modPath = pathToFileURL(modPath).href
}

Ctor = await import(modPath).then((m) => m.default || m)
} catch {
// Fallback to trying to load the reporter from node_modules resolution.
Expand Down

0 comments on commit f763f88

Please sign in to comment.