Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): fix custom workspace-generator options #12821

Merged
40 changes: 20 additions & 20 deletions packages/nx/src/command-line/nx-commands.ts
Expand Up @@ -784,33 +784,33 @@ async function withCustomGeneratorOptions(
const options = [];
const positionals = [];

Object.entries(schema.properties as WorkspaceGeneratorProperties).forEach(
([name, prop]) => {
const option: { name: string; definition: OptionArgumentDefinition } = {
Object.entries(
(schema.properties ?? {}) as WorkspaceGeneratorProperties
).forEach(([name, prop]) => {
const option: { name: string; definition: OptionArgumentDefinition } = {
name,
definition: {
describe: prop.description,
type: prop.type,
default: prop.default,
choices: prop.enum,
},
};
if (schema.required && schema.required.includes(name)) {
option.definition.demandOption = true;
}
options.push(option);
if (isPositionalProperty(prop)) {
positionals.push({
name,
definition: {
describe: prop.description,
type: prop.type,
default: prop.default,
choices: prop.enum,
},
};
if (schema.required && schema.required.includes(name)) {
option.definition.demandOption = true;
}
options.push(option);
if (isPositionalProperty(prop)) {
positionals.push({
name,
definition: {
describe: prop.description,
type: prop.type,
choices: prop.enum,
},
});
}
});
}
);
});

let command = generatorName;
positionals.forEach(({ name }) => {
Expand Down