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

pmcelhaney / counterfact / 8840743817

25 Apr 2024 11:32PM UTC coverage: 86.763% (+0.03%) from 86.733%
8840743817

push

github

web-flow
Merge pull request #869 from pmcelhaney/chokidar-settings

don't re-process watch files unnecessarily at startup

894 of 988 branches covered (90.49%)

Branch coverage included in aggregate %.

21 of 24 new or added lines in 4 files covered. (87.5%)

2947 of 3439 relevant lines covered (85.69%)

43.61 hits per line

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

89.06
/src/server/code-generator.ts
1
import { type FSWatcher, watch } from "chokidar";
2✔
2

2✔
3
import { generate } from "../typescript-generator/generate.js";
2✔
4
import { waitForEvent } from "../util/wait-for-event.js";
2✔
5
import { CHOKIDAR_OPTIONS } from "./constants.js";
2✔
6

2✔
7
export class CodeGenerator extends EventTarget {
2✔
8
  private readonly openapiPath: string;
4✔
9

4✔
10
  private readonly destination: string;
4✔
11

4✔
12
  private watcher: FSWatcher | undefined;
4✔
13

4✔
14
  public constructor(openApiPath: string, destination: string) {
4✔
15
    super();
4✔
16
    this.openapiPath = openApiPath;
4✔
17
    this.destination = destination;
4✔
18
  }
4✔
19

4✔
20
  public async watch() {
4✔
21
    await generate(this.openapiPath, this.destination);
4✔
22

4✔
23
    if (this.openapiPath.startsWith("http")) {
4!
24
      return;
×
25
    }
×
26

4✔
27
    this.watcher = watch(this.openapiPath, CHOKIDAR_OPTIONS).on(
4✔
28
      "change",
4✔
29
      () => {
4✔
30
        // eslint-disable-next-line promise/prefer-await-to-then
2✔
31
        void generate(this.openapiPath, this.destination).then(
2✔
32
          () => {
2✔
33
            this.dispatchEvent(new Event("generate"));
2✔
34
            return true;
2✔
35
          },
2✔
36
          () => {
2✔
NEW
37
            this.dispatchEvent(new Event("failed"));
×
NEW
38
            return false;
×
NEW
39
          },
×
40
        );
2✔
41
      },
2✔
42
    );
4✔
43

4✔
44
    await waitForEvent(this.watcher, "ready");
4✔
45
  }
4✔
46

4✔
47
  public async stopWatching(): Promise<void> {
4✔
48
    await this.watcher?.close();
4✔
49
  }
4✔
50
}
4✔
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