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

pmcelhaney / counterfact / 6512240392

13 Oct 2023 07:17PM UTC coverage: 86.447% (-1.4%) from 87.815%
6512240392

Pull #606

github

pmcelhaney
add changeset for fixing shared context
Pull Request #606: fix root context not shared

747 of 823 branches covered (0.0%)

Branch coverage included in aggregate %.

99 of 99 new or added lines in 6 files covered. (100.0%)

2455 of 2881 relevant lines covered (85.21%)

39.72 hits per line

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

0.0
/src/migrations/0.27.js
1
import { readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
×
2
import { join } from "node:path";
×
3

×
4
function processFile(filePath) {
×
5
  const content = readFileSync(filePath, "utf8");
×
6

×
7
  if (
×
8
    content.includes("export type ContextType =") ||
×
9
    content.includes("export type { ContextType }")
×
10
  ) {
×
11
    return;
×
12
  }
×
13

×
14
  if (content.includes("export default new Context")) {
×
15
    writeFileSync(filePath, "export type ContextType = typeof Context;\n", {
×
16
      flag: "a",
×
17
    });
×
18
  } else {
×
19
    writeFileSync(
×
20
      filePath,
×
21
      'export type { ContextType } from "../$.context";\n',
×
22
    );
×
23
  }
×
24
}
×
25

×
26
function migrateContextFiles(path) {
×
27
  const items = readdirSync(path);
×
28

×
29
  for (const item of items) {
×
30
    const itemPath = join(path, item);
×
31
    const stats = statSync(itemPath);
×
32

×
33
    if (stats.isDirectory()) {
×
34
      migrateContextFiles(itemPath);
×
35
    }
×
36

×
37
    if (stats.isFile() && item === "$.context.ts") {
×
38
      processFile(itemPath);
×
39
    }
×
40
  }
×
41
}
×
42

×
43
export function migrate(rootPath) {
×
44
  migrateContextFiles(join(rootPath, "paths"));
×
45
}
×
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