Skip to content

Commit

Permalink
fix: handle hyphenation when looking for generator defaults
Browse files Browse the repository at this point in the history
Fixes #1313
  • Loading branch information
Cammisuli committed Aug 2, 2022
1 parent 9efb7bf commit 31a75ce
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions libs/schema/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type OptionPropertyDescription = Schema['properties'][number];

export type CliOption = {
name: string;
originalName?: string;
positional?: number;
alias?: string;
hidden?: boolean;
Expand Down
4 changes: 3 additions & 1 deletion libs/server/src/lib/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ export async function normalizeSchema(

const nxOptions = options.map((option) => {
const xPrompt: XPrompt | undefined = option['x-prompt'];
const workspaceDefault = projectDefaults && projectDefaults[option.name];
const workspaceDefault =
projectDefaults?.[option.originalName ?? option.name];
const $default = option.$default;

const nxOption: Option = {
Expand Down Expand Up @@ -346,6 +347,7 @@ function schemaToOptions(
const name = config?.hyphenate ? names(option).fileName : option;
cliOptions.push({
name,
originalName: option,
positional,
...currentProperty,
});
Expand Down
4 changes: 2 additions & 2 deletions libs/vscode/tasks/src/lib/select-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { GlobalConfigurationStore } from '@nx-console/vscode/configuration';
import { nxWorkspace } from '@nx-console/vscode/nx-workspace';
import { QuickPickItem, window } from 'vscode';

async function readWorkspaceJsonDefaults(workspacePath: string): Promise<any> {
async function readWorkspaceJsonDefaults(): Promise<any> {
const { workspace } = await nxWorkspace();

let defaults = workspace.generators;
Expand Down Expand Up @@ -65,7 +65,7 @@ export async function getGeneratorOptions(
workspaceType: 'ng' | 'nx'
): Promise<Option[]> {
const generatorSchema = await readAndCacheJsonFile(generatorPath);
const workspaceDefaults = await readWorkspaceJsonDefaults(workspacePath);
const workspaceDefaults = await readWorkspaceJsonDefaults();
const defaults =
workspaceDefaults &&
workspaceDefaults[collectionName] &&
Expand Down

0 comments on commit 31a75ce

Please sign in to comment.