webdriverio-automation
Version:
WebdriverIO-Automation android ios project
42 lines (41 loc) • 1.49 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.isWindows = exports.sanitizeCliOptionValue = exports.formatCliArgs = exports.getFilePath = void 0;
const path_1 = require("path");
const param_case_1 = require("param-case");
const FILE_EXTENSION_REGEX = /\.[0-9a-z]+$/i;
function getFilePath(filePath, defaultFilename) {
let absolutePath = path_1.resolve(filePath);
if (!FILE_EXTENSION_REGEX.test(path_1.basename(absolutePath))) {
absolutePath = path_1.join(absolutePath, defaultFilename);
}
return absolutePath;
}
exports.getFilePath = getFilePath;
function formatCliArgs(args) {
if (Array.isArray(args)) {
return args.map(arg => sanitizeCliOptionValue(arg));
}
const cliArgs = [];
for (const key in args) {
let value = args[key];
if ((typeof value === 'boolean' && !value) || value === null) {
continue;
}
cliArgs.push(`--${param_case_1.paramCase(key)}`);
if (typeof value !== 'boolean' && value !== null) {
cliArgs.push(sanitizeCliOptionValue(value));
}
}
return cliArgs;
}
exports.formatCliArgs = formatCliArgs;
function sanitizeCliOptionValue(value) {
const valueString = String(value);
return /\s/.test(valueString) ? `'${valueString}'` : valueString;
}
exports.sanitizeCliOptionValue = sanitizeCliOptionValue;
function isWindows() {
return process.platform === 'win32';
}
exports.isWindows = isWindows;
;