From 36e360c0d1208a1b4d8d9797416bd17eb4308e37 Mon Sep 17 00:00:00 2001 From: damyanpetev Date: Wed, 18 Feb 2026 14:17:29 +0200 Subject: [PATCH] fix(commands,list): do not use `this` in handler --- packages/cli/lib/commands/doc.ts | 2 +- packages/cli/lib/commands/list.ts | 2 +- packages/cli/lib/commands/types.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/cli/lib/commands/doc.ts b/packages/cli/lib/commands/doc.ts index f917366e4..fe5cccb37 100644 --- a/packages/cli/lib/commands/doc.ts +++ b/packages/cli/lib/commands/doc.ts @@ -27,7 +27,7 @@ const doc: DocCommandType = { if (!argv.term) { const answer = await PromptSession.chooseTerm(); argv.term = answer; - await this.handler(argv); + await doc.handler(argv); } else if (!Util.isAlphanumericExt(argv.term)) { return Util.error(`The search term '${argv.term}' is not valid.` + "\n" + "Name should start with a letter and can also contain numbers, dashes and spaces.", diff --git a/packages/cli/lib/commands/list.ts b/packages/cli/lib/commands/list.ts index be7549350..8b8db2f84 100644 --- a/packages/cli/lib/commands/list.ts +++ b/packages/cli/lib/commands/list.ts @@ -40,7 +40,7 @@ const command: CommandType = { const templatesByGroup = []; const controlGroups: string[] = []; - const framework: Framework = this.templateManager.getFrameworkById(argv.framework); + const framework: Framework = command.templateManager.getFrameworkById(argv.framework); if (!framework) { return Util.error("Wrong framework provided", "red"); } diff --git a/packages/cli/lib/commands/types.ts b/packages/cli/lib/commands/types.ts index 7ea043e32..a3e9d3d52 100644 --- a/packages/cli/lib/commands/types.ts +++ b/packages/cli/lib/commands/types.ts @@ -70,7 +70,7 @@ export interface CommandType extends CommandModule<{}, any> { templateManager?: TemplateManager; /** Handler function that will be called by yargs after the command line has been parsed. */ - handler(argv: ArgumentsCamelCase); + handler(/** do not use `this` in handler */this: void, argv: ArgumentsCamelCase); } export interface NewCommandType extends CommandType {