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

pmcelhaney / counterfact / 6629231258

24 Oct 2023 03:40PM UTC coverage: 82.644% (-3.5%) from 86.129%
6629231258

Pull #599

github

pmcelhaney
changesets for two new features
Pull Request #599: don't expose moduleLoader

736 of 822 branches covered (0.0%)

Branch coverage included in aggregate %.

311 of 311 new or added lines in 7 files covered. (100.0%)

2383 of 2952 relevant lines covered (80.72%)

36.84 hits per line

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

0.0
/src/server/repl.ts
1
import repl from "node:repl";
×
2

×
3
import type { Config } from "./config.js";
×
4
import type { ContextRegistry } from "./context-registry.js";
×
5

×
6
export function startRepl(contextRegistry: ContextRegistry, config: Config) {
×
7
  const replServer = repl.start("> ");
×
8

×
9
  replServer.defineCommand("counterfact", {
×
10
    action() {
×
11
      process.stdout.write(
×
12
        "This is a read-eval-print loop (REPL), the same as the one you get when you run node with no arguments.\n",
×
13
      );
×
14
      process.stdout.write(
×
15
        "Except that it's connected to the running server, which you can access with the following globals:\n\n",
×
16
      );
×
17
      process.stdout.write(
×
18
        "- loadContext('/some/path'): to access the context object for a given path\n",
×
19
      );
×
20
      process.stdout.write(
×
21
        "- context: the root context ( same as loadContext('/') )\n",
×
22
      );
×
23
      process.stdout.write(
×
24
        "\nFor more information, see https://counterfact.dev/docs/usage.html\n\n",
×
25
      );
×
26

×
27
      this.clearBufferedCommand();
×
28
      this.displayPrompt();
×
29
    },
×
30

×
31
    help: "Get help with Counterfact",
×
32
  });
×
33

×
34
  replServer.defineCommand("proxy", {
×
35
    action(state) {
×
36
      if (state === "on") {
×
37
        config.proxyEnabled = true;
×
38
      }
×
39

×
40
      if (state === "off") {
×
41
        config.proxyEnabled = false;
×
42
      }
×
43

×
44
      process.stdout.write(
×
45
        `Proxy is ${config.proxyEnabled ? "on" : "off"}: ${config.proxyUrl}\n`,
×
46
      );
×
47

×
48
      this.clearBufferedCommand();
×
49
      this.displayPrompt();
×
50
    },
×
51

×
52
    help: "proxy [on|off] - turn the proxy on or off; proxy - print proxy info",
×
53
  });
×
54

×
55
  replServer.context.loadContext = (path: string) => contextRegistry.find(path);
×
56
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
×
57
  replServer.context.context = replServer.context.loadContext("/");
×
58

×
59
  return replServer;
×
60
}
×
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