diff --git a/NodeApp/src/commander/CommanderApp.ts b/NodeApp/src/commander/CommanderApp.ts index d7ecd85f6471d907525a42449cd8b3e95602dae1..1f3619e55f76e4d40af303dc9fa0f39969521f03 100644 --- a/NodeApp/src/commander/CommanderApp.ts +++ b/NodeApp/src/commander/CommanderApp.ts @@ -14,7 +14,21 @@ import SessionCommand from './auth/SessionCommand'; class CommanderApp { - program: Command = new Command(); + public program: Command = new Command(); + + private readonly commandHookDisabled: Array<string> = [ 'completion' ]; + + private hasToExecuteHook(actionCommand: Command): boolean { + if ( actionCommand.parent == null ) { + return true; + } else { + if ( this.commandHookDisabled.includes(actionCommand.name()) ) { + return false; + } + + return this.hasToExecuteHook(actionCommand.parent); + } + } constructor() { this.program @@ -30,11 +44,16 @@ class CommanderApp { .option('-H, --host <string>', 'override the Dojo API endpoint', ClientsSharedConfig.apiURL) .option('-I, --interactive', 'show interactive interface when available', Config.interactiveMode) .addOption(new Option('--debug').hideHelp()) - .hook('preAction', () => { - this.warnDevelopmentVersion(); - }).hook('postAction', () => { - this.informNewVersion(); - }); + .hook('preAction', (_thisCommand: Command, actionCommand: Command) => { + if ( this.hasToExecuteHook(actionCommand) ) { + this.warnDevelopmentVersion(); + } + }) + .hook('postAction', (_thisCommand: Command, actionCommand: Command) => { + if ( this.hasToExecuteHook(actionCommand) ) { + this.informNewVersion(); + } + }); this.program.on('option:host', () => { ClientsSharedConfig.apiURL = this.program.opts().host;