Fix the "new" breaking of loading of plugins on Windows GitHub actions. (#4426)

This commit is contained in:
Peter Hedenskog 2025-02-02 09:55:49 +01:00 committed by GitHub
parent 8af2110858
commit e0d004beec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 5 deletions

View File

@ -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',
@ -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
@ -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_) {