@nx/react-native
Version:
40 lines (39 loc) • 1.67 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.createProcessOptions = createProcessOptions;
const devkit_1 = require("@nx/devkit");
/**
* Logic copied from `packages/react-native/src/utils/get-cli-options.ts`,
* which was used by most executors to map their options to CLI options.
*/
function createProcessOptions(executorName, optionKeysToIgnore, optionKeysInCamelName) {
return (projectName, options, migrationLogs) => {
const args = [];
for (const optionKey of Object.keys(options)) {
const optionValue = options[optionKey];
delete options[optionKey];
if (optionKeysToIgnore.includes(optionKey)) {
migrationLogs.addLog({
project: projectName,
executorName,
log: `Unable to migrate '${optionKey}' to inferred target configuration.`,
});
continue;
}
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)) {
args.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
args.push(`--${cliKey}`);
}
else {
args.push(`--${cliKey}`, optionValue);
}
}
options.args = args;
};
}
;