Archived
1
0

Attempt to require spdlog and node-pty

This commit is contained in:
Asher
2019-02-22 18:54:02 -06:00
parent 59eec534b6
commit 80d9baadc0
3 changed files with 46 additions and 14 deletions

View File

@ -2,9 +2,7 @@ import { client } from "@coder/ide/src/fill/client";
import { EventEmitter } from "events";
import * as nodePty from "node-pty";
import { ActiveEvalHelper } from "@coder/protocol";
// Use this to prevent Webpack from hijacking require.
declare var __non_webpack_require__: typeof require;
import { logger } from "@coder/logger";
/**
* Implementation of nodePty for the browser.
@ -17,7 +15,7 @@ class Pty implements nodePty.IPty {
public constructor(file: string, args: string[] | string, options: nodePty.IPtyForkOptions) {
this.ae = client.run((ae, file, args, options) => {
const nodePty = __non_webpack_require__("node-pty") as typeof import("node-pty");
const nodePty = ae.require("node-pty") as typeof import("node-pty");
ae.preserveEnv(options);
@ -54,6 +52,8 @@ class Pty implements nodePty.IPty {
};
}, file, args, options);
this.ae.on("error", (error) => logger.error(error.message));
this.ae.on("pid", (pid) => this._pid = pid);
this.ae.on("process", (process) => this._process = process);

View File

@ -3,10 +3,8 @@ import { RotatingLogger as NodeRotatingLogger } from "spdlog";
import { logger } from "@coder/logger";
import { client } from "@coder/ide/src/fill/client";
declare var __non_webpack_require__: typeof require;
const ae = client.run((ae) => {
const spdlog = __non_webpack_require__("spdlog") as typeof import("spdlog");
const spdlog = ae.require("spdlog") as typeof import("spdlog");
const loggers = new Map<number, NodeRotatingLogger>();
ae.on("new", (id: number, name: string, filePath: string, fileSize: number, fileCount: number) => {