Archived
1
0

Add evaluation helpers (#33)

* Add evaluation helpers

* Make some helpers only available server-side

They don't make any sense on the client side.

* Fork the right thing
This commit is contained in:
Asher
2019-02-22 15:56:29 -06:00
committed by GitHub
parent de3fbd689f
commit 8b8bef015e
17 changed files with 306 additions and 247 deletions

View File

@ -380,7 +380,7 @@ class Dialog {
}
private async list(directory: string): Promise<ReadonlyArray<DialogEntry>> {
return ideClient.evaluate((directory) => {
return ideClient.evaluate((_helper, directory) => {
const fs = __non_webpack_require__("fs") as typeof import("fs");
const util = __non_webpack_require__("util") as typeof import("util");
const path = __non_webpack_require__("path") as typeof import("path");

View File

@ -1,7 +1,7 @@
import { client } from "@coder/ide/src/fill/client";
import { EventEmitter } from "events";
import * as nodePty from "node-pty";
import { ActiveEval } from "@coder/protocol";
import { ActiveEvalHelper } from "@coder/protocol";
// Use this to prevent Webpack from hijacking require.
declare var __non_webpack_require__: typeof require;
@ -11,16 +11,15 @@ declare var __non_webpack_require__: typeof require;
*/
class Pty implements nodePty.IPty {
private readonly emitter = new EventEmitter();
private readonly ae: ActiveEval;
private readonly ae: ActiveEvalHelper;
private _pid = -1;
private _process = "";
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 { preserveEnv } = __non_webpack_require__("@coder/ide/src/fill/evaluation") as typeof import("@coder/ide/src/fill/evaluation");
preserveEnv(options);
ae.preserveEnv(options);
const ptyProc = nodePty.spawn(file, args, options);