fix: stop rewriting dev during release publish (#22982)

This commit is contained in:
Kit Langton 2026-04-17 22:53:19 -04:00 committed by GitHub
parent 3573019916
commit 24fb9b1296
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 120 additions and 50 deletions

View file

@ -6,9 +6,19 @@ import { fileURLToPath } from "url"
const dir = fileURLToPath(new URL("..", import.meta.url))
process.chdir(dir)
async function published(name: string, version: string) {
return (await $`npm view ${name}@${version} version`.nothrow()).exitCode === 0
}
await $`bun tsc`
const pkg = await import("../package.json").then((m) => m.default)
const pkg = await import("../package.json").then(
(m) => m.default as { name: string; version: string; exports: Record<string, string> },
)
const original = JSON.parse(JSON.stringify(pkg))
if (await published(pkg.name, pkg.version)) {
console.log(`already published ${pkg.name}@${pkg.version}`)
process.exit(0)
}
for (const [key, value] of Object.entries(pkg.exports)) {
const file = value.replace("./src/", "./dist/").replace(".ts", "")
// @ts-ignore