Skip to content

Commit

Permalink
fix(turbo/gen): fix generate name arg (#4921)
Browse files Browse the repository at this point in the history
  • Loading branch information
tknickman committed May 12, 2023
1 parent 6be898a commit 574a3ba
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
25 changes: 14 additions & 11 deletions packages/turbo-gen/src/commands/generate/prompts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import inquirer from "inquirer";
import type { Generator } from "../../utils/plop";
import { logger } from "@turbo/utils";

export async function customGenerators({
generators,
Expand All @@ -8,24 +9,26 @@ export async function customGenerators({
generators: Array<Generator | inquirer.Separator>;
generator?: string;
}) {
if (
generator &&
generators.find(
(g) => !(g instanceof inquirer.Separator) && g.name === generator
)
) {
return {
selectedGenerator: generator,
};
if (generator) {
if (
generators.find(
(g) => !(g instanceof inquirer.Separator) && g.name === generator
)
) {
return {
selectedGenerator: generator,
};
}

logger.warn(`Generator "${generator}" not found`);
console.log();
}

const generatorAnswer = await inquirer.prompt<{
selectedGenerator: string;
}>({
type: "list",
name: "selectedGenerator",
default: generator,
when: !generator,
message: `Select generator to run`,
choices: generators.map((gen) => {
if (gen instanceof inquirer.Separator) {
Expand Down
6 changes: 3 additions & 3 deletions packages/turbo-gen/src/commands/raw/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { generate, type CustomGeneratorOptions } from "../generate";
import { convertCase } from "@turbo/utils";

interface MinimalOptions {
generator?: string;
generatorName?: string;
[arg: string]: any;
}

Expand All @@ -25,8 +25,8 @@ export async function raw(command: string, options: { json: string }) {
await add(incomingOptions as TurboGeneratorOptions);
break;
case "generate":
const { generator } = incomingOptions;
await generate(generator, incomingOptions as CustomGeneratorOptions);
const { generatorName } = incomingOptions;
await generate(generatorName, incomingOptions as CustomGeneratorOptions);
break;
default:
console.error(
Expand Down

1 comment on commit 574a3ba

@vercel
Copy link

@vercel vercel bot commented on 574a3ba May 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.