From 8abc405953d415603014e1a7ba8d4d7bb3109a71 Mon Sep 17 00:00:00 2001 From: Richard Roozenboom Date: Mon, 7 Nov 2022 22:09:10 +0100 Subject: [PATCH] fix(core): fix custom workspace-generator options (#12821) Closes: #12677 --- packages/nx/src/command-line/nx-commands.ts | 40 ++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/packages/nx/src/command-line/nx-commands.ts b/packages/nx/src/command-line/nx-commands.ts index 7066eb286fba0..f296a62069390 100644 --- a/packages/nx/src/command-line/nx-commands.ts +++ b/packages/nx/src/command-line/nx-commands.ts @@ -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 }) => {