MCPcopy Index your code
hub / github.com/anomalyco/opencode / backupAndStripLegacy

Function backupAndStripLegacy

packages/opencode/src/config/tui-migrate.ts:89–113  ·  view source on GitHub ↗
(file: string, source: string)

Source from the content-addressed store, hash-verified

87}
88
89async function backupAndStripLegacy(file: string, source: string) {
90 const backup = file + ".tui-migration.bak"
91 const hasBackup = await Filesystem.exists(backup)
92 const backed = hasBackup
93 ? true
94 : await Filesystem.write(backup, source)
95 .then(() => true)
96 .catch(() => false)
97 if (!backed) return false
98
99 const text = ["theme", "keybinds", "tui"].reduce((acc, key) => {
100 const edits = modify(acc, [key], undefined, {
101 formattingOptions: {
102 insertSpaces: true,
103 tabSize: 2,
104 },
105 })
106 if (!edits.length) return acc
107 return applyEdits(acc, edits)
108 }, source)
109
110 return Filesystem.write(file, text)
111 .then(() => true)
112 .catch(() => false)
113}
114
115async function opencodeFiles(input: { directories: string[]; cwd: string }) {
116 const files = [

Callers 1

migrateTuiConfigFunction · 0.85

Calls 2

writeMethod · 0.80
existsMethod · 0.45

Tested by

no test coverage detected