UNPKG

@appium/docutils

Version:

Documentation generation utilities for Appium and related projects

38 lines 1.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.argify = void 0; exports.kebabCase = kebabCase; /** * Converts an object of string values to an array of arguments for CLI * * Supports `boolean` and `number` values as well. `boolean`s are assumed to be flags which default * to `false`, so they will only be added to the array if the value is `true`. */ const argify = (obj) => { const args = []; for (const [key, value] of Object.entries(obj)) { if (value === true) { args.push(`--${key}`); } else if (value === false || value === undefined) { continue; } else { args.push(`--${key}`, String(value)); } } return args; }; exports.argify = argify; /** * Converts a string to kebab-case. * @param value Input string * @returns Kebab-cased string */ function kebabCase(value) { return value .replace(/([a-z0-9])([A-Z])/g, '$1-$2') .replace(/[_\s]+/g, '-') .toLowerCase(); } //# sourceMappingURL=cli.js.map