summaryrefslogtreecommitdiff
path: root/os.ts
blob: 409c1186f24dabd2f37c00174001bbc3fa1cf8e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { ModuleInfo } from "./types";
import { sendMsg } from "./dispatch";

export function exit(code = 0): void {
  sendMsg("os", { exit: { code } });
}

export function sourceCodeFetch(
  moduleSpecifier: string,
  containingFile: string
): ModuleInfo {
  const res = sendMsg("os", {
    sourceCodeFetch: { moduleSpecifier, containingFile }
  });
  return res.sourceCodeFetchRes;
}

export function sourceCodeCache(
  filename: string,
  sourceCode: string,
  outputCode: string
): void {
  sendMsg("os", {
    sourceCodeCache: { filename, sourceCode, outputCode }
  });
}