MCPcopy
hub / github.com/lingodotdev/lingo.dev / _loadLockfile

Function _loadLockfile

packages/cli/src/cli/utils/lockfile.ts:71–89  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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();

Callers 1

createLockfileHelperFunction · 0.85

Calls 4

_getLockfilePathFunction · 0.85
deduplicateLockfileYamlFunction · 0.85
parseMethod · 0.80
logMethod · 0.80

Tested by

no test coverage detected