import { Config } from './Config.js'; import { ExpectedError } from 'clime'; export function getConfigValue(config: Config | null, key: K): NonNullable | null; export function getConfigValue( config: Config | null, key: K, throws: true ): NonNullable; export function getConfigValue( config: Config | null, key: K, throws: boolean = false ): NonNullable | null { const value = config?.[key]; if (value == null) { if (throws) { throw new ExpectedError(`Please set the ${key} option in your config.json or as a command line parameter`); } return null; } return value!; }