Skip to content

Commit

Permalink
Fix the "new" breaking of loading of plugins on Windows GitHub action…
Browse files Browse the repository at this point in the history
…s. (#4426)
  • Loading branch information
soulgalore authored Feb 2, 2025
1 parent 8af2110 commit e0d004b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/core/pluginLoader.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import path from 'node:path';
import { readdir as _readdir } from 'node:fs';
import { promisify } from 'node:util';
import { fileURLToPath, pathToFileURL } from 'node:url';

import { importGlobalSilent } from 'import-global';
const readdir = promisify(_readdir);
const __dirname = path.dirname(import.meta.url);
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const defaultPlugins = new Set([
'browsertime',
Expand Down Expand Up @@ -49,7 +51,7 @@ export async function parsePluginNames(options) {
return pluginNames;
};

const files = await readdir(new URL(pluginsDir));
const files = await readdir(pluginsDir);

const builtins = files.map(name => path.basename(name, '.js'));
// eslint-disable-next-line unicorn/no-array-callback-reference
Expand All @@ -60,9 +62,9 @@ export async function loadPlugins(pluginNames, options, context, queue) {
const plugins = [];
for (let name of pluginNames) {
try {
let { default: plugin } = await import(
path.join(pluginsDir, name, 'index.js')
);
const pluginPath = path.join(pluginsDir, name, 'index.js');
const pluginUrl = pathToFileURL(pluginPath).href;
let { default: plugin } = await import(pluginUrl);
let p = new plugin(options, context, queue);
plugins.push(p);
} catch (error_) {
Expand Down

0 comments on commit e0d004b

Please sign in to comment.