Skip to content

Commit

Permalink
apply suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
GeoffreyBooth committed Dec 20, 2022
1 parent c3cea01 commit d896dce
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/internal/test_runner/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,17 @@ async function getReportersMap(reporters, destinations) {
const destination = kBuiltinDestinations.get(destinations[i]) ?? createWriteStream(destinations[i]);

// Load the test reporter passed to --test-reporter
const reporterPath = kBuiltinReporters.get(name) ?? name;
const reporterSpecifier = kBuiltinReporters.get(name) ?? name;
let cwd;
try {
cwd = process.cwd() + '/';
} catch {}
const { esmLoader } = require('internal/process/esm_loader');
const { pathToFileURL } = require('internal/url');
const file = isAbsolute(reporterPath) ? pathToFileURL(reporterPath).href : reporterPath;
let reporter = await esmLoader.import(file, undefined, { __proto__: null });
let reporter = await esmLoader.import(
reporterSpecifier,
cwd == null ? 'file:///' : pathToFileURL(cwd).href,
ObjectCreate(null),
);

if (reporter?.default) {
reporter = reporter.default;
Expand Down

0 comments on commit d896dce

Please sign in to comment.