()
| 91 | }; |
| 92 | }, |
| 93 | async loadLock() { |
| 94 | const lockfileContent = tryReadFile(lockfilePath, null); |
| 95 | |
| 96 | if (!lockfileContent) { |
| 97 | return { |
| 98 | version: 1, |
| 99 | checksums: {}, |
| 100 | } as const; |
| 101 | } |
| 102 | |
| 103 | // Deduplicate using the universal function |
| 104 | const { deduplicatedContent, duplicatesRemoved } = deduplicateLockfileYaml(lockfileContent); |
| 105 | |
| 106 | // Write back to disk if duplicates were found |
| 107 | if (duplicatesRemoved > 0) { |
| 108 | writeFile(lockfilePath, deduplicatedContent); |
| 109 | console.log( |
| 110 | `Removed ${duplicatesRemoved} duplicate ${duplicatesRemoved === 1 ? "entry" : "entries"} from i18n.lock`, |
| 111 | ); |
| 112 | } |
| 113 | |
| 114 | const parsed = LockSchema.parse(YAML.parse(deduplicatedContent)); |
| 115 | return parsed; |
| 116 | }, |
| 117 | async saveLock(lockData: LockData) { |
| 118 | const lockfileYaml = YAML.stringify(lockData); |
| 119 | writeFile(lockfilePath, lockfileYaml); |
nothing calls this directly
no test coverage detected