UNPKG

@sap/cli-core

Version:

Command-Line Interface (CLI) Core Module

18 lines (17 loc) 854 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.create = void 0; const config_1 = require("../../config"); const logger_1 = require("../../logger"); const create = (option, throwIfExists = true) => async () => async () => { const config = (0, config_1.get)(); const { trace } = (0, logger_1.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`); } }; exports.create = create;