• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

akoidan / hotkey-hub / 25769683921

13 May 2026 12:06AM UTC coverage: 69.484% (+1.2%) from 68.296%
25769683921

push

github

web-flow
Merge pull request #56 from akoidan/fix-variable-declaration

Improve variable definition

170 of 361 branches covered (47.09%)

Branch coverage included in aggregate %.

119 of 131 new or added lines in 22 files covered. (90.84%)

1 existing line in 1 file now uncovered.

1351 of 1828 relevant lines covered (73.91%)

26.26 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.86
/src/local/implementation/macro-local-handler.ts
1
import {Injectable, Logger} from '@nestjs/common';
2✔
2
import {ConfigService} from '@/config/config-service';
2✔
3
import {VariableResolutionService} from '@/local/variable-resolution.service';
2✔
4
import {DelayService} from '@/local/delay.service';
2✔
5
import {BaseLocalHandler} from '@/local/base-local-handler';
2✔
6
import {MacroLocalCommand} from '@/config/types/local/local-commands';
7
import {UnknownCommand} from '@/config/types/commands';
8
import {Delay} from '@/config/types/remote/base-remote-command';
9
import {SemaphorService} from '@/semaphor/semaphor-service';
2✔
10

11
@Injectable()
12
export class MacroLocalHandler extends BaseLocalHandler {
2✔
13
  constructor(
14
    private readonly configService: ConfigService,
24✔
15
    private readonly variableService: VariableResolutionService,
24✔
16
    private readonly semaphoreService: SemaphorService,
24✔
17
    private readonly delayService: DelayService,
24✔
18
    protected readonly logger: Logger,
24✔
19
  ) {
20
    super();
24✔
21
  }
22

23
  canHandle(command: UnknownCommand): command is MacroLocalCommand {
24
    return 'macro' in (command as MacroLocalCommand);
33✔
25
  }
26

27
  public async execute(
28
    input: MacroLocalCommand,
29
    combDelayAfter: number | undefined,
30
    combDelayBefore: number | undefined,
31
    tId: string | undefined | null,
32
  ): Promise<void> {
33
    const macroDefinition = this.configService.getMacros()[input.macro];
1✔
34
    if (!macroDefinition) {
1!
UNCOV
35
      throw new Error(`Macro ${input.macro} not found.`);
×
36
    }
37
        await this.semaphoreService.spawnPromiseChild(
1✔
38
      `m=${input.macro}`,
39
      async() => {
40
        if (typeof input.delayBefore === 'number') { // ignore if it's a variable or undefined
1!
41
          // if it's a macro, delay in this macro won't be passed down
42
          // but would be await after any commands in this macro has run yet as expected, this is why on top we are not passing it
43
          await this.delayService.awaitDelay(input.delayBefore as number, undefined, 'before', 'macro');
×
44
        }
45
        for (let i = 0; i < macroDefinition.commands.length; i++) {
1✔
46
          await this.semaphoreService.spawnPromiseChild(
3✔
47
            `c=${String(i)}`,
48
            async() => {
49
              const preparedCommand = this.variableService.replaceMacroVariables(
3✔
50
                null,
51
                macroDefinition.commands[i],
52
                input.variables,
53
                macroDefinition.variables,
54
                macroDefinition.requiredVariables!,
55
              );
56
              const delayA = ((preparedCommand as Delay).delayAfter as number | undefined) ?? combDelayAfter;
3✔
57
              const delayB = ((preparedCommand as Delay).delayBefore as number | undefined) ?? combDelayBefore;
3✔
58
              await this.startChain.handle(preparedCommand, delayA, delayB, tId);
3✔
59
            }
60
          );
61
        }
62
        // commands in this macro has been already ran in the loop
63
        // await delay before the next command after this macro runs
64
        if (typeof input.delayAfter === 'number') { // ignore if it's a variable or undefined
1!
65
          await this.delayService.awaitDelay(input.delayAfter as number, undefined, 'after', 'macro'); // if it's a macro, delay in this macro won't be passed down
×
66
          // but would be await after all commands in this macro as expected, this is why on top we are not passing it
67
        }
68
      },
69
      '='
70
    );
71
  }
72
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc