/
githubmirror
/
grafana
Обзор
Документация
Войти
/
githubmirror
/
grafana
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
scripts/cli/env-util.ts
25 строк
868 B
Jack Westbrook
Build: Refactor Webpack config to TS (#121181)
28 апр 2026, 13:45
Не верифицирован
28 апр 2026, 13:45
0a10a5d
Код
Авторство
О чём код?
import { parse } from 'ini'; import { existsSync, readFileSync } from 'node:fs'; export const getEnvConfig = (grafanaRoot: string): Record<string, unknown> => { 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 const env: Record<string, unknown> = {}; for (const [key, value] of Object.entries(merged)) { env[`frontend_dev_${key}`] = value; } return env; };