Skip to content

Commit 8383f40

Browse files
committed
Preserve custom_modes.json for rollback if necessary
1 parent 5643fd1 commit 8383f40

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/__tests__/migrateSettings.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,13 @@ describe("Settings Migration", () => {
167167

168168
// Verify file operations
169169
expect(mockWrite).toHaveBeenCalledWith(newCustomModesYaml, expect.any(String), "utf-8")
170-
expect(mockUnlink).toHaveBeenCalledWith(legacyCustomModesJson)
170+
// We don't delete the original JSON file to allow for rollback
171+
expect(mockUnlink).not.toHaveBeenCalled()
172+
173+
// Verify log message mentions preservation of original file
174+
expect(mockOutputChannel.appendLine).toHaveBeenCalledWith(
175+
expect.stringContaining("original JSON file preserved for rollback purposes"),
176+
)
171177
})
172178

173179
it("should handle corrupt JSON gracefully", async () => {

src/utils/migrateSettings.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,11 @@ async function migrateCustomModesToYaml(settingsDir: string, outputChannel: vsco
9898
// Write YAML file
9999
await fs.writeFile(newYamlPath, yamlContent, "utf-8")
100100

101-
try {
102-
// Delete old JSON file - wrapped in try/catch to handle unlink errors
103-
await fs.unlink(oldJsonPath)
104-
} catch (unlinkError) {
105-
// Just log the error but continue - file migration succeeded
106-
outputChannel.appendLine(`Warning: Could not delete old JSON file: ${unlinkError}`)
107-
}
108-
109-
outputChannel.appendLine("Successfully migrated custom_modes.json to YAML format")
101+
// Keeping the old JSON file for backward compatibility
102+
// This allows users to roll back if needed
103+
outputChannel.appendLine(
104+
"Successfully migrated custom_modes.json to YAML format (original JSON file preserved for rollback purposes)",
105+
)
110106
} catch (parseError) {
111107
// Handle corrupt JSON file
112108
outputChannel.appendLine(

0 commit comments

Comments
 (0)