2024-07-08 14:40:45 +00:00
|
|
|
import path from "path";
|
|
|
|
import { getInstanceRoot } from "app/server/lib/places";
|
|
|
|
import { IGristCoreConfig, loadGristCoreConfigFile } from "app/server/lib/configCore";
|
|
|
|
import log from "app/server/lib/log";
|
|
|
|
|
|
|
|
const globalConfigPath: string = path.join(getInstanceRoot(), 'config.json');
|
|
|
|
let cachedGlobalConfig: IGristCoreConfig | undefined = undefined;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves the cached grist config, or loads it from the default global path.
|
|
|
|
*/
|
2024-07-17 21:46:28 +00:00
|
|
|
export function getGlobalConfig(): IGristCoreConfig {
|
2024-07-08 14:40:45 +00:00
|
|
|
if (!cachedGlobalConfig) {
|
|
|
|
log.info(`Loading config file from ${globalConfigPath}`);
|
2024-07-17 21:46:28 +00:00
|
|
|
cachedGlobalConfig = loadGristCoreConfigFile(globalConfigPath);
|
2024-07-08 14:40:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return cachedGlobalConfig;
|
|
|
|
}
|