UNPKG

@sap/cli-core

Version:

Command-Line Interface (CLI) Core Module

21 lines (20 loc) 622 B
import { get } from "../config/index.js"; export const getOptionValueFromConfig = (option, defaultValue) => { const config = get(); if (!config.options[option.longName] && typeof defaultValue !== "string" && !defaultValue) { throw new Error(`no value found for option ${option.longName}`); } return config.options[option.longName] ? config.options[option.longName] : defaultValue; }; export const getOptionValueFromConfigGracefully = (option) => { try { return getOptionValueFromConfig(option); } catch (err) { return undefined; } };