(file: string, source: string)
| 87 | } |
| 88 | |
| 89 | async 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 | |
| 115 | async function opencodeFiles(input: { directories: string[]; cwd: string }) { |
| 116 | const files = [ |
no test coverage detected