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

Function getConfig

packages/cli/src/cli/utils/config.ts:6–26  ·  view source on GitHub ↗
(resave = true)

Source from the content-addressed store, hash-verified

4import { I18nConfig, parseI18nConfig } from "@lingo.dev/_spec";
5
6export function getConfig(resave = true): I18nConfig | null {
7 const configFilePath = _getConfigFilePath();
8
9 const configFileExists = fs.existsSync(configFilePath);
10 if (!configFileExists) {
11 return null;
12 }
13
14 const fileContents = fs.readFileSync(configFilePath, "utf8");
15 const rawConfig = JSON.parse(fileContents);
16
17 const result = parseI18nConfig(rawConfig);
18 const didConfigChange = !_.isEqual(rawConfig, result);
19
20 if (resave && didConfigChange) {
21 // Ensure the config is saved with the latest version / schema
22 saveConfig(result);
23 }
24
25 return result;
26}
27
28export function saveConfig(config: I18nConfig) {
29 const configFilePath = _getConfigFilePath();

Callers 11

status.tsFile · 0.90
purge.tsFile · 0.90
init.tsFile · 0.90
lockfile.tsFile · 0.90
i18n.tsFile · 0.90
cleanup.tsFile · 0.90
files.tsFile · 0.90
preserved-keys.tsFile · 0.90
ignored-keys.tsFile · 0.90
locked-keys.tsFile · 0.90
setupFunction · 0.90

Calls 4

_getConfigFilePathFunction · 0.85
parseI18nConfigFunction · 0.85
saveConfigFunction · 0.85
parseMethod · 0.80

Tested by

no test coverage detected