diff --git a/src/storage/collab.ts b/src/storage/collab.ts index 7264560..78cf63d 100644 --- a/src/storage/collab.ts +++ b/src/storage/collab.ts @@ -32,7 +32,7 @@ function saveCollab(data: CollabSchema): void { if (!existsSync(dir)) { mkdirSync(dir, { recursive: true }); } - writeFileSync(collabPath, JSON.stringify(data, null, 2)); + writeFileSync(collabPath, JSON.stringify(data, null, 2) + '\n'); } export const collabStorage = { diff --git a/src/storage/snapshots.ts b/src/storage/snapshots.ts index 1f7a38d..799406a 100644 --- a/src/storage/snapshots.ts +++ b/src/storage/snapshots.ts @@ -58,7 +58,7 @@ function loadMeta(problemId: string): SnapshotMeta { function saveMeta(problemId: string, meta: SnapshotMeta): void { ensureSnapshotDir(problemId); - writeFileSync(getMetaPath(problemId), JSON.stringify(meta, null, 2)); + writeFileSync(getMetaPath(problemId), JSON.stringify(meta, null, 2) + '\n'); } export const snapshotStorage = { diff --git a/src/storage/timer.ts b/src/storage/timer.ts index fc61fd7..f6ba73a 100644 --- a/src/storage/timer.ts +++ b/src/storage/timer.ts @@ -41,7 +41,7 @@ function saveTimer(data: TimerSchema): void { if (!existsSync(dir)) { mkdirSync(dir, { recursive: true }); } - writeFileSync(timerPath, JSON.stringify(data, null, 2)); + writeFileSync(timerPath, JSON.stringify(data, null, 2) + '\n'); } export const timerStorage = { diff --git a/src/storage/version.ts b/src/storage/version.ts index 48c1b6a..3928381 100644 --- a/src/storage/version.ts +++ b/src/storage/version.ts @@ -32,7 +32,7 @@ function loadCache(): VersionCache | null { function saveCache(cache: VersionCache): void { ensureDir(); - writeFileSync(VERSION_FILE, JSON.stringify(cache, null, 2)); + writeFileSync(VERSION_FILE, JSON.stringify(cache, null, 2) + '\n'); } export const versionStorage = { diff --git a/src/storage/workspaces.ts b/src/storage/workspaces.ts index 2d25aec..69ee82c 100644 --- a/src/storage/workspaces.ts +++ b/src/storage/workspaces.ts @@ -35,7 +35,7 @@ function loadRegistry(): WorkspaceRegistry { function saveRegistry(registry: WorkspaceRegistry): void { ensureDir(LEETCODE_DIR); - writeFileSync(WORKSPACES_FILE, JSON.stringify(registry, null, 2)); + writeFileSync(WORKSPACES_FILE, JSON.stringify(registry, null, 2) + '\n'); } function normalizeWorkspaceName(name: string): string | null { @@ -154,14 +154,14 @@ export const workspaceStorage = { // Write config const configPath = join(wsDir, 'config.json'); - writeFileSync(configPath, JSON.stringify(config, null, 2)); + writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n'); // Initialize empty timer and collab writeFileSync( join(wsDir, 'timer.json'), - JSON.stringify({ solveTimes: {}, activeTimer: null }, null, 2) + JSON.stringify({ solveTimes: {}, activeTimer: null }, null, 2) + '\n' ); - writeFileSync(join(wsDir, 'collab.json'), JSON.stringify({ session: null }, null, 2)); + writeFileSync(join(wsDir, 'collab.json'), JSON.stringify({ session: null }, null, 2) + '\n'); // Update registry registry.workspaces.push(wsName); @@ -233,7 +233,7 @@ export const workspaceStorage = { const currentConfig = this.getConfig(wsName); const newConfig = { ...currentConfig, ...config }; - writeFileSync(join(wsDir, 'config.json'), JSON.stringify(newConfig, null, 2)); + writeFileSync(join(wsDir, 'config.json'), JSON.stringify(newConfig, null, 2) + '\n'); }, /**