UNPKG

@sap/cli-core

Version:

Command-Line Interface (CLI) Core Module

18 lines (17 loc) 786 B
import { set, get } from "../../../../config/index.js"; import { CONFIG_PASSCODE_FUNCTION, OPTION_PASSCODE, } from "../../../../constants.js"; export const create = () => async () => async () => { const config = get(); if (!config[CONFIG_PASSCODE_FUNCTION] || typeof config[CONFIG_PASSCODE_FUNCTION] !== "function") { throw new Error("passcode function not available from configuration or provided argument is no function"); } let passcode = config.options[OPTION_PASSCODE.longName]; if (!passcode) { passcode = await config[CONFIG_PASSCODE_FUNCTION](); if (!passcode) { throw new Error(`provided passcode function did not return a passcode. returned value was ${passcode}`); } set({ passcode }); } };