Skip to content

Commit f87f2dd

Browse files
committed
fix: write .npmrc in package dir for bun publish auth discovery
1 parent 80d6374 commit f87f2dd

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

packages/teamcode/script/publish.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@ const publish = async (dir: string, name: string, ver: string) => {
2222
console.log(`already published ${name}@${ver}`)
2323
return
2424
}
25-
// bun publish reads NPM_TOKEN or BUN_AUTH_TOKEN env var
26-
await $`bun publish --access public --tag ${Script.channel}`.cwd(dir)
25+
// Write .npmrc in the package dir so the publish subprocess finds it
26+
const token = process.env.NPM_TOKEN || process.env.BUN_AUTH_TOKEN || ""
27+
await Bun.write(`${dir}/.npmrc`, `//registry.npmjs.org/:_authToken=${token}\n`)
28+
try {
29+
await $`bun publish --access public --tag ${Script.channel}`.cwd(dir)
30+
} finally {
31+
await $`rm -f ${dir}/.npmrc`.nothrow()
32+
}
2733
}
2834

2935
// Publish each binary package (scoped names, e.g., @teamcode-ai/linux-x64)

0 commit comments

Comments
 (0)