feat: add bun_no_cache configuration option to disable Bun cache during package installation

This commit is contained in:
Longlone 2025-12-09 11:46:21 +08:00
parent 0569e8652c
commit 0adc76a1db
2 changed files with 11 additions and 0 deletions

View file

@ -4,6 +4,7 @@ import { Log } from "../util/log"
import path from "path"
import { NamedError } from "@opencode-ai/util/error"
import { readableStreamToText } from "bun"
import { Config } from "../config/config"
import { createRequire } from "module"
import { Lock } from "../util/lock"
@ -76,6 +77,12 @@ export namespace BunProc {
// Build command arguments
const args = ["add", "--force", "--exact", "--cwd", Global.Path.cache, pkg + "@" + version]
// Add --no-cache flag if configured
const config = await Config.get()
if (config.bun_no_cache) {
args.push("--no-cache")
}
// Let Bun handle registry resolution:
// - If .npmrc files exist, Bun will use them automatically
// - If no .npmrc files exist, Bun will default to https://registry.npmjs.org

View file

@ -671,6 +671,10 @@ export namespace Config {
url: z.string().optional().describe("Enterprise URL"),
})
.optional(),
bun_no_cache: z
.boolean()
.optional()
.describe("Disable Bun cache when installing packages (adds --no-cache flag)"),
experimental: z
.object({
hook: z