( plugin: ConfigPluginV1.Spec, configFilepath: string, )
| 40 | // Path-like specs are resolved relative to the config file that declared them so merges later on do not |
| 41 | // accidentally reinterpret `./plugin.ts` relative to some other directory. |
| 42 | export async function resolvePluginSpec( |
| 43 | plugin: ConfigPluginV1.Spec, |
| 44 | configFilepath: string, |
| 45 | ): Promise<ConfigPluginV1.Spec> { |
| 46 | const spec = pluginSpecifier(plugin) |
| 47 | if (!isPathPluginSpec(spec)) return plugin |
| 48 | |
| 49 | const base = path.dirname(configFilepath) |
| 50 | const file = (() => { |
| 51 | if (spec.startsWith("file://")) return spec |
| 52 | if (path.isAbsolute(spec) || /^[A-Za-z]:[\\/]/.test(spec)) return pathToFileURL(spec).href |
| 53 | return pathToFileURL(path.resolve(base, spec)).href |
| 54 | })() |
| 55 | |
| 56 | const resolved = await resolvePathPluginTarget(file).catch(() => file) |
| 57 | |
| 58 | if (Array.isArray(plugin)) return [resolved, plugin[1]] |
| 59 | return resolved |
| 60 | } |
| 61 | |
| 62 | // Dedupe on the load identity (package name for npm specs, exact file URL for local specs), but keep the |
| 63 | // full Origin so downstream code still knows which config file won and where follow-up writes should go. |
nothing calls this directly
no test coverage detected