()
| 69 | }; |
| 70 | |
| 71 | function _loadLockfile() { |
| 72 | const lockfilePath = _getLockfilePath(); |
| 73 | if (!fs.existsSync(lockfilePath)) { |
| 74 | return LockfileSchema.parse({}); |
| 75 | } |
| 76 | const content = fs.readFileSync(lockfilePath, "utf-8"); |
| 77 | |
| 78 | const { deduplicatedContent, duplicatesRemoved } = deduplicateLockfileYaml(content); |
| 79 | |
| 80 | if (duplicatesRemoved > 0) { |
| 81 | fs.writeFileSync(lockfilePath, deduplicatedContent); |
| 82 | console.log( |
| 83 | `Removed ${duplicatesRemoved} duplicate ${duplicatesRemoved === 1 ? "entry" : "entries"} from i18n.lock`, |
| 84 | ); |
| 85 | } |
| 86 | |
| 87 | const parsed = LockfileSchema.parse(YAML.parse(deduplicatedContent)); |
| 88 | return parsed; |
| 89 | } |
| 90 | |
| 91 | function _saveLockfile(lockfile: Z.infer<typeof LockfileSchema>) { |
| 92 | const lockfilePath = _getLockfilePath(); |
no test coverage detected