( source: PluginSource, spec: string, target: string, id: string | undefined, pkg?: PluginPackage, )
| 304 | } |
| 305 | |
| 306 | export async function resolvePluginId( |
| 307 | source: PluginSource, |
| 308 | spec: string, |
| 309 | target: string, |
| 310 | id: string | undefined, |
| 311 | pkg?: PluginPackage, |
| 312 | ) { |
| 313 | if (source === "file") { |
| 314 | if (id) return id |
| 315 | throw new TypeError(`Path plugin ${spec} must export id`) |
| 316 | } |
| 317 | if (id) return id |
| 318 | const hit = pkg ?? (await readPluginPackage(target)) |
| 319 | if (typeof hit.json.name !== "string" || !hit.json.name.trim()) { |
| 320 | throw new TypeError(`Plugin package ${hit.pkg} is missing name`) |
| 321 | } |
| 322 | return hit.json.name.trim() |
| 323 | } |
no test coverage detected