Skip to content

Commit

Permalink
Return plugin.path
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Feb 13, 2022
1 parent 03b699b commit 4d47233
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/config/plugin/lib/each.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const addPlugin = async function (
},
) {
const propName = getPropName(name, index, pluginsCount)
const plugin = await importPlugin(id, propName, builtins)
const { plugin, path } = await importPlugin(id, propName, builtins)
const { config: pluginConfigDefinitions, ...pluginA } = await normalizeShape(
plugin,
shape,
Expand All @@ -32,7 +32,7 @@ export const addPlugin = async function (
pluginConfigDefinitions,
item,
})
return { ...pluginA, config: pluginConfigA }
return { plugin: pluginA, path, config: pluginConfigA }
}

const getPropName = function (name, index, pluginsCount) {
Expand Down
11 changes: 4 additions & 7 deletions src/config/plugin/lib/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,14 @@ import { isBuiltinId } from './id.js'
// share the same top-level properties. However, they will share deep
// properties by reference.
export const importPlugin = async function (id, propName, builtins) {
const plugin = await importPluginById(id, propName, builtins)
return { ...plugin }
}

const importPluginById = async function (id, propName, builtins) {
if (isBuiltinId(id, builtins)) {
return await builtins[id]()
const plugin = await builtins[id]()
return { plugin: { ...plugin } }
}

try {
return await import(pathToFileURL(id))
const plugin = await import(pathToFileURL(id))
return { plugin: { ...plugin }, path: id }
} catch (error) {
throw wrapError(
error,
Expand Down
10 changes: 7 additions & 3 deletions src/config/plugin/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,17 @@ const normalizeConfigProp = async function (
return
}

const propValueA = await addPlugins(propValue, pluginTypeA, {
const plugins = await addPlugins(propValue, pluginTypeA, {
sharedConfig: config,
context,
cwd,
})
const propValueB = propValueA.map(removeEmptyValues)
return [propName, propValueB]
const pluginsA = plugins.map(normalizePlugin)
return [propName, pluginsA]
}

const PLUGIN_TYPES = [RUNNER_PLUGIN_TYPE, REPORTER_PLUGIN_TYPE]

const normalizePlugin = function ({ plugin, config }) {
return removeEmptyValues({ ...plugin, config })
}

0 comments on commit 4d47233

Please sign in to comment.