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: handle hyphenation when looking for generator defaults #1315

Merged
merged 1 commit into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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