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

akoidan / hotkey-hub / 26063976158

18 May 2026 10:24PM UTC coverage: 68.863% (-0.2%) from 69.033%
26063976158

push

github

web-flow
Merge pull request #61 from akoidan/develop

develop

171 of 367 branches covered (46.59%)

Branch coverage included in aggregate %.

4 of 11 new or added lines in 1 file covered. (36.36%)

1386 of 1894 relevant lines covered (73.18%)

25.85 hits per line

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

35.48
/src/native/native-module.ts
1
import {Inject, Logger, LogLevel, Module, OnModuleDestroy, OnModuleInit} from '@nestjs/common';
2✔
2
import {INativeModule, Native} from '@/native/native-model';
2✔
3
import clc from 'cli-color';
2✔
4
import {getAsset, isSea} from 'node:sea';
2✔
5
import {tmpdir} from 'node:os';
2✔
6
import {join} from 'node:path';
2✔
7

8
import {createRequire} from 'node:module';
2✔
9
import {mkdtemp, writeFile} from 'node:fs/promises';
2✔
10
import {LOG_LEVEL} from '@/app/app-model';
2✔
11

12
// avoid rewriting native module on reload, reuse same instance
13
// otherwise ddl cache can trigger different issues on hotkey key load
14
let cache: INativeModule|null = null;
2✔
15

16
@Module({
17
  providers: [
18
    Logger,
19
    {
20
      provide: Native,
21
      useFactory: async(): Promise<INativeModule> => {
NEW
22
        if (cache) {
×
NEW
23
          return cache;
×
24
        }
25
        if (isSea()) {
×
26
          const tmp = await mkdtemp(join(tmpdir(), 'sea-'));
×
27
          const pathOnDisk = join(tmp, 'native.node');
×
28
          await writeFile(pathOnDisk, Buffer.from(getAsset('native')));
×
29
          const requireFromHere = createRequire(__filename);
×
30
          // eslint-disable-next-line
NEW
31
          cache = requireFromHere(pathOnDisk) as INativeModule;
×
32
        } else {
33
          // eslint-disable-next-line
NEW
34
          const bindings = require('bindings') as any;
×
35
          // eslint-disable-next-line
NEW
36
          cache= bindings('native') as INativeModule;
×
37
        }
NEW
38
        return cache;
×
39
      },
40
    },
41
  ],
42
  exports: [Native],
43
})
44
export class NativeModule implements OnModuleInit, OnModuleDestroy {
2✔
45
  constructor(
46
    private readonly logger: Logger,
×
47
    @Inject(Native)
48
    private readonly native: INativeModule,
×
49
    @Inject(LOG_LEVEL)
50
    private readonly logLevel: LogLevel
×
51
  ) {
52
  }
53

54
  onModuleDestroy(): void {
NEW
55
    this.native.cleanupHotkeys();
×
56
  }
57

58
  onModuleInit(): any {
59
    this.native.setLoggerLevel(['debug' , 'verbose'].includes(this.logLevel));
×
60
    this.logger.log(`Loaded native library from ${clc.bold.green(this.native.path)}`);
×
61
  }
62
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc