refactor: replace Bun.write with Filesystem.write in config files
This commit is contained in:
@@ -1240,7 +1240,7 @@ export namespace Config {
|
|||||||
if (!parsed.data.$schema && isFile) {
|
if (!parsed.data.$schema && isFile) {
|
||||||
parsed.data.$schema = "https://opencode.ai/config.json"
|
parsed.data.$schema = "https://opencode.ai/config.json"
|
||||||
const updated = original.replace(/^\s*\{/, '{\n "$schema": "https://opencode.ai/config.json",')
|
const updated = original.replace(/^\s*\{/, '{\n "$schema": "https://opencode.ai/config.json",')
|
||||||
await Bun.write(options.path, updated).catch(() => {})
|
await Filesystem.write(options.path, updated).catch(() => {})
|
||||||
}
|
}
|
||||||
const data = parsed.data
|
const data = parsed.data
|
||||||
if (data.plugin && isFile) {
|
if (data.plugin && isFile) {
|
||||||
@@ -1401,3 +1401,5 @@ export namespace Config {
|
|||||||
return state().then((x) => x.directories)
|
return state().then((x) => x.directories)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Filesystem.write
|
||||||
|
Filesystem.write
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ export async function migrateTuiConfig(input: MigrateInput) {
|
|||||||
if (extracted.keybinds !== undefined) payload.keybinds = extracted.keybinds
|
if (extracted.keybinds !== undefined) payload.keybinds = extracted.keybinds
|
||||||
if (tui) Object.assign(payload, tui)
|
if (tui) Object.assign(payload, tui)
|
||||||
|
|
||||||
const wrote = await Bun.write(target, JSON.stringify(payload, null, 2))
|
const wrote = await Filesystem.write(target, JSON.stringify(payload, null, 2))
|
||||||
.then(() => true)
|
.then(() => true)
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
log.warn("failed to write tui migration target", { from: file, to: target, error })
|
log.warn("failed to write tui migration target", { from: file, to: target, error })
|
||||||
@@ -104,7 +104,7 @@ async function backupAndStripLegacy(file: string, source: string) {
|
|||||||
const hasBackup = await Filesystem.exists(backup)
|
const hasBackup = await Filesystem.exists(backup)
|
||||||
const backed = hasBackup
|
const backed = hasBackup
|
||||||
? true
|
? true
|
||||||
: await Bun.write(backup, source)
|
: await Filesystem.write(backup, source)
|
||||||
.then(() => true)
|
.then(() => true)
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
log.warn("failed to backup source config during tui migration", { path: file, backup, error })
|
log.warn("failed to backup source config during tui migration", { path: file, backup, error })
|
||||||
@@ -123,7 +123,7 @@ async function backupAndStripLegacy(file: string, source: string) {
|
|||||||
return applyEdits(acc, edits)
|
return applyEdits(acc, edits)
|
||||||
}, source)
|
}, source)
|
||||||
|
|
||||||
return Bun.write(file, text)
|
return Filesystem.write(file, text)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
log.info("stripped tui keys from server config", { path: file, backup })
|
log.info("stripped tui keys from server config", { path: file, backup })
|
||||||
return true
|
return true
|
||||||
|
|||||||
Reference in New Issue
Block a user