diff --git a/e2e/cli-help.test.ts b/e2e/cli-help.test.ts index c522527..f82c121 100644 --- a/e2e/cli-help.test.ts +++ b/e2e/cli-help.test.ts @@ -114,6 +114,7 @@ describe("nf dev --help", () => { expect(stdout).toContain("run your game in dev mode"); expect(stdout).toContain("--directory"); expect(stdout).toContain("--generate"); + expect(stdout).toContain("--editor"); }); }); diff --git a/src/action/actions/dev.action.ts b/src/action/actions/dev.action.ts index 8666e15..e7b88fc 100644 --- a/src/action/actions/dev.action.ts +++ b/src/action/actions/dev.action.ts @@ -1,4 +1,4 @@ -import { type Input, getDevGenerateInput, getDirectoryInput } from "@lib/input"; +import { type Input, getDevGenerateInput, getDirectoryInput, getEditorInput } from "@lib/input"; import { PackageManagerFactory } from "@lib/package-manager"; import { Messages } from "@lib/ui"; @@ -15,20 +15,22 @@ export class DevAction extends AbstractAction { const directory = getDirectoryInput(options); const generate = getDevGenerateInput(options); - const tasks = this.buildTaskList(directory, generate); + const editor = getEditorInput(options); + const tasks = this.buildTaskList(directory, generate, editor); await Promise.all(tasks); return { keepAlive: true }; } - private buildTaskList(directory: string, generate: boolean): Promise[] { + private buildTaskList(directory: string, generate: boolean, editor: boolean): Promise[] { const tasks: Promise[] = []; + const extraFlags = editor ? ["--editor"] : []; if (generate) { - tasks.push(this.runSubCommand("generate", directory, { silent: true })); + tasks.push(this.runSubCommand("generate", directory, { silent: true, extraFlags })); } - tasks.push(this.runSubCommand("build", directory, { silent: true })); + tasks.push(this.runSubCommand("build", directory, { silent: true, extraFlags })); tasks.push(this.runSubCommand("start", directory, { silent: false })); return tasks; @@ -37,11 +39,12 @@ export class DevAction extends AbstractAction { private async runSubCommand( command: string, directory: string, - options: { silent: boolean }, + options: { silent: boolean; extraFlags?: string[] }, ): Promise { await runSafe(async () => { const packageManager = await PackageManagerFactory.find(directory); - await packageManager.runDev(directory, "nf", {}, [command, "--watch"], options.silent); + const args = [command, "--watch", ...(options.extraFlags ?? [])]; + await packageManager.runDev(directory, "nf", {}, args, options.silent); }); } } diff --git a/src/command/commands/dev.command.ts b/src/command/commands/dev.command.ts index 44bad2c..a985e9f 100644 --- a/src/command/commands/dev.command.ts +++ b/src/command/commands/dev.command.ts @@ -8,6 +8,7 @@ interface DevOptions { directory?: string; config?: string; generate?: boolean; + editor?: boolean; } export class DevCommand extends AbstractCommand { @@ -18,11 +19,13 @@ export class DevCommand extends AbstractCommand { .option("-d, --directory ", "specify the working directory of the command") .option("-c, --config ", "path to the config file", CONFIG_FILE_NAME) .option("--generate", "generate app from config", false) + .option("-e, --editor", "run the editor", false) .action(async (rawOptions: DevOptions) => { const options = AbstractCommand.mapToInput({ directory: rawOptions.directory, config: rawOptions.config, generate: rawOptions.generate, + editor: rawOptions.editor, }); await this.action.run(new Map(), options);