(pkgDir: string)
| 766 | // --------------------------------------------------------------------------- |
| 767 | |
| 768 | const packageAlreadyPublished = async (pkgDir: string) => { |
| 769 | const pkg = (await Bun.file(join(pkgDir, "package.json")).json()) as { |
| 770 | name?: string; |
| 771 | version?: string; |
| 772 | }; |
| 773 | |
| 774 | if (!pkg.name || !pkg.version) { |
| 775 | throw new Error(`Missing name/version in ${join(pkgDir, "package.json")}`); |
| 776 | } |
| 777 | |
| 778 | const proc = Bun.spawn(["npm", "view", `${pkg.name}@${pkg.version}`, "version"], { |
| 779 | cwd: pkgDir, |
| 780 | stdio: ["ignore", "ignore", "ignore"], |
| 781 | }); |
| 782 | |
| 783 | return (await proc.exited) === 0; |
| 784 | }; |
| 785 | |
| 786 | /** Recognize npm error output for "this version already exists." Used to |
| 787 | * make publish retries idempotent — if a previous workflow run got partway |
no test coverage detected