fix(frontend): make linting work with cjs util file

This commit is contained in:
Tom Ratcliffe
2025-03-03 09:51:12 +01:00
committed by Jack Westbrook
parent f6b49880df
commit c5d89b53d8
4 changed files with 18 additions and 10 deletions
+35
View File
@@ -0,0 +1,35 @@
// @ts-check
const { parse } = require('ini');
const { readFileSync, existsSync } = require('node:fs');
const path = require('path');
const getEnvConfig = () => {
const grafanaRoot = path.join(__dirname, '../..');
const defaultSettings = readFileSync(`${grafanaRoot}/conf/defaults.ini`, {
encoding: 'utf-8',
});
const customSettings = existsSync(`${grafanaRoot}/conf/custom.ini`)
? readFileSync(`${grafanaRoot}/conf/custom.ini`, {
encoding: 'utf-8',
})
: '';
const defaults = parse(defaultSettings);
const custom = parse(customSettings);
const merged = { ...defaults.frontend_dev, ...custom.frontend_dev };
// Take all frontend keys from the ini file and prefix with `frontend_dev_`,
// so they can be added to `process.env` elsewhere
/** @type {Record<string, unknown>} */
const env = {};
for (const [key, value] of Object.entries(merged)) {
env[`frontend_dev_${key}`] = value;
}
return env;
};
module.exports = getEnvConfig;