1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00
denoland-deno/os.ts
Ryan Dahl d765300de5 Move away from oneof in msg.proto
This is due to the size added to msg.pb.js for every new message. See
comment in msg.proto.
2018-05-25 15:24:29 -04:00

34 lines
890 B
TypeScript

import { ModuleInfo } from "./types";
import { sendMsg } from "./dispatch";
import { main as pb } from "./msg.pb";
import { assert } from "./util";
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 }
});
assert(res.command === pb.Msg.Command.SOURCE_CODE_FETCH_RES);
return {
moduleName: res.sourceCodeFetchResModuleName,
filename: res.sourceCodeFetchResFilename,
sourceCode: res.sourceCodeFetchResSourceCode,
outputCode: res.sourceCodeFetchResOutputCode
};
}
export function sourceCodeCache(
filename: string,
sourceCode: string,
outputCode: string
): void {
sendMsg("os", {
sourceCodeCache: { filename, sourceCode, outputCode }
});
}