@sap/cli-core
Version:
Command-Line Interface (CLI) Core Module
14 lines (13 loc) • 731 B
JavaScript
import { get as getConfig } from "../../config/index.js";
import { get } from "../../logger/index.js";
export const create = (option, throwIfExists = true) => async () => async () => {
const config = getConfig();
const { trace } = get("commands.handler.checkOptionsExistence");
trace(`checking options existence ${option.longName} in config, value in config is ${config.options[option.longName]}, throw error if option exists ${throwIfExists}`);
if (config.options[option.longName] && throwIfExists) {
throw new Error(`option ${option.longName} already set`);
}
else if (!config.options[option.longName] && !throwIfExists) {
throw new Error(`option ${option.longName} is not set`);
}
};