(target: string)
| 281 | } |
| 282 | |
| 283 | export async function readPluginManifest(target: string): Promise<ManifestResult> { |
| 284 | const pkg = await readPluginPackage(target).then( |
| 285 | (item) => ({ |
| 286 | ok: true as const, |
| 287 | item, |
| 288 | }), |
| 289 | (error: unknown) => ({ |
| 290 | ok: false as const, |
| 291 | error, |
| 292 | }), |
| 293 | ) |
| 294 | if (!pkg.ok) { |
| 295 | return { |
| 296 | ok: false, |
| 297 | code: "manifest_read_failed", |
| 298 | file: target, |
| 299 | error: pkg.error, |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | const targets = await Promise.resolve() |
| 304 | .then(() => packageTargets(pkg.item)) |
| 305 | .then( |
| 306 | (item) => ({ ok: true as const, item }), |
| 307 | (error: unknown) => ({ ok: false as const, error }), |
| 308 | ) |
| 309 | |
| 310 | if (!targets.ok) { |
| 311 | return { |
| 312 | ok: false, |
| 313 | code: "manifest_read_failed", |
| 314 | file: pkg.item.pkg, |
| 315 | error: targets.error, |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | if (!targets.item.length) { |
| 320 | return { |
| 321 | ok: false, |
| 322 | code: "manifest_no_targets", |
| 323 | file: pkg.item.pkg, |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | return { |
| 328 | ok: true, |
| 329 | targets: targets.item, |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | function patchDir(input: PatchInput) { |
| 334 | if (input.global) return input.config ?? Global.Path.config |
no test coverage detected