UNPKG

beam-cli

Version:

A beautifully simple CLI for running Lighthouse audits on a statically generated (SSG) website

21 lines (20 loc) 652 B
import { ensureFileExistence } from '../fs/file.js'; import { loadJSONFile } from '../fs/json.js'; export const loadConfigFile = async (path) => { if (path) { const exists = ensureFileExistence(path); if (!exists) { throw new Error('Unable to find config file specified within command flags.'); } } const configPath = path ?? '.beam.json'; const exists = ensureFileExistence(configPath); if (!exists) return {}; try { return (await loadJSONFile(configPath)); } catch { throw new Error(`Unable to load and parse configuration file at: ${configPath}`); } };