@nx/react-native
Version:
33 lines (32 loc) • 1.51 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCliOptions = getCliOptions;
const devkit_1 = require("@nx/devkit");
/**
* This function normalizes the options passed in to the Nx and returns an array of strings that can be passed to the React Native CLI.
* @param options Nx options
* @param optionKeysToIgnore Keys to ignore
* @param optionKeysInCamelName Keys that are in camel case. Most react native cli options are in kebab case, but some are in camel case.
* @returns options that can be passed to the React Native CLI
*/
function getCliOptions(options, optionKeysToIgnore = [], optionKeysInCamelName = []) {
return Object.keys(options).reduce((acc, optionKey) => {
const optionValue = options[optionKey];
if (!optionKeysToIgnore.includes(optionKey)) {
const cliKey = optionKeysInCamelName.includes(optionKey)
? (0, devkit_1.names)(optionKey).propertyName
: (0, devkit_1.names)(optionKey).fileName; // cli uses kebab case as default
if (Array.isArray(optionValue)) {
acc.push(`--${cliKey}`, optionValue.join(','));
}
else if (typeof optionValue === 'boolean' && optionValue) {
// no need to pass in the value when it is true, just the flag name
acc.push(`--${cliKey}`);
}
else {
acc.push(`--${cliKey}`, optionValue);
}
}
return acc;
}, []);
}
;