Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: windows reporter reference #104

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading