UNPKG

@jil/args

Version:

A convention based argument parsing and formatting library, with strict validation checks

31 lines 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createScope = void 0; const Scope_1 = require("../Scope"); function camelCase(value) { return value.replace(/-([a-z0-9])/giu, (match, char) => String(char).toUpperCase()); } function createScope(optionName, optionConfigs, options) { let name = optionName; let negated = false; // Check for negated types if (name.startsWith('no-')) { negated = true; name = name.slice(3); } // Convert option to camel case if (name.includes('-')) { name = camelCase(name); } // Create scope const scope = new Scope_1.Scope(name, optionConfigs[name]); scope.negated = negated; // When capturing multiples, we need to persist the array // so we can append. Avoid using the default array though. if (scope.config.multiple) { scope.value = options[name] === scope.config.default ? [] : options[name]; } return scope; } exports.createScope = createScope; //# sourceMappingURL=createScope.js.map