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

pmcelhaney / counterfact / 3596104599

pending completion
3596104599

push

github

GitHub
Update dependency fs-extra to v11

380 of 401 branches covered (94.76%)

Branch coverage included in aggregate %.

1777 of 1999 relevant lines covered (88.89%)

21.89 hits per line

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

49.04
/src/typescript-generator/repository.js
1
import nodePath from "node:path";
1✔
2
import fs from "node:fs/promises";
1✔
3
import { constants as fsConstants } from "node:fs";
1✔
4

1✔
5
import prettier from "prettier";
1✔
6

1✔
7
import { Script } from "./script.js";
1✔
8

1✔
9
// eslint-disable-next-line no-underscore-dangle
1✔
10
const __dirname = nodePath.dirname(new URL(import.meta.url).pathname);
1✔
11

1✔
12
async function ensureDirectoryExists(filePath) {
×
13
  const directory = nodePath.dirname(filePath);
×
14

×
15
  try {
×
16
    await fs.access(directory, fsConstants.W_OK);
×
17
  } catch {
×
18
    await fs.mkdir(directory, { recursive: true });
×
19
  }
×
20
}
×
21

1✔
22
export class Repository {
1✔
23
  constructor() {
1✔
24
    this.scripts = new Map();
9✔
25
  }
9✔
26

1✔
27
  get(path) {
1✔
28
    if (this.scripts.has(path)) {
98✔
29
      return this.scripts.get(path);
46✔
30
    }
46✔
31

52✔
32
    const script = new Script(this, path);
52✔
33

52✔
34
    this.scripts.set(path, script);
52✔
35

52✔
36
    return script;
52✔
37
  }
52✔
38

1✔
39
  async finished() {
1✔
40
    while (
1✔
41
      Array.from(this.scripts.values()).some((script) => script.isInProgress())
1✔
42
    ) {
1✔
43
      // eslint-disable-next-line no-await-in-loop
1✔
44
      await Promise.all(
1✔
45
        Array.from(this.scripts.values(), (script) => script.finished())
1✔
46
      );
1✔
47
    }
1✔
48
  }
1✔
49

1✔
50
  copyCoreFiles(destination) {
1✔
51
    const path = nodePath.join(destination, "response-builder-factory.ts");
×
52

×
53
    process.stdout.write(`writing ${path}\n`);
×
54

×
55
    return fs.copyFile(
×
56
      nodePath.join(__dirname, "../../templates/response-builder-factory.ts"),
×
57
      path
×
58
    );
×
59
  }
×
60

1✔
61
  async writeFiles(destination) {
1✔
62
    await this.finished();
×
63

×
64
    const writeFiles = Array.from(
×
65
      this.scripts.entries(),
×
66
      async ([path, script]) => {
×
67
        const contents = prettier.format(script.contents(), {
×
68
          parser: "typescript",
×
69
        });
×
70

×
71
        const fullPath = nodePath.join(destination, path);
×
72

×
73
        await ensureDirectoryExists(fullPath);
×
74

×
75
        if (
×
76
          path.startsWith("paths") &&
×
77
          (await fs
×
78
            .stat(fullPath)
×
79
            .then((stat) => stat.isFile())
×
80
            .catch(() => false))
×
81
        ) {
×
82
          process.stdout.write(`not overwriting ${fullPath}\n`);
×
83

×
84
          return;
×
85
        }
×
86

×
87
        await fs.writeFile(fullPath, contents);
×
88

×
89
        process.stdout.write(`writing ${fullPath}\n`);
×
90
      }
×
91
    );
×
92

×
93
    await Promise.all(writeFiles);
×
94

×
95
    await this.copyCoreFiles(destination);
×
96
  }
×
97
}
1✔
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

© 2025 Coveralls, Inc