diff --git a/packages/ide/test/fs.test.ts b/packages/ide/test/fs.test.ts index c4e84ad..856ae47 100644 --- a/packages/ide/test/fs.test.ts +++ b/packages/ide/test/fs.test.ts @@ -11,7 +11,7 @@ const fs = require("../src/fill/fs") as typeof import("fs"); describe("fs", () => { let i = 0; - const coderDir = path.join(os.tmpdir(), "coder"); + const coderDir = path.join(os.tmpdir(), "coder", "fs"); const testFile = path.join(__dirname, "fs.test.ts"); const tmpFile = (): string => path.join(coderDir, `${i++}`); const createTmpFile = async (): Promise => { @@ -22,6 +22,13 @@ describe("fs", () => { }; beforeAll(async () => { + try { + await util.promisify(nativeFs.mkdir)(path.dirname(coderDir)); + } catch (error) { + if (error.code !== "EEXIST") { + throw error; + } + } await util.promisify(rimraf)(coderDir); await util.promisify(nativeFs.mkdir)(coderDir); }); @@ -332,7 +339,7 @@ describe("fs", () => { describe("mkdtemp", () => { it("should create temp dir", async () => { await expect(util.promisify(fs.mkdtemp)(coderDir + "/")) - .resolves.toMatch(/^\/tmp\/coder\/[a-zA-Z0-9]{6}/); + .resolves.toMatch(/^\/tmp\/coder\/fs\/[a-zA-Z0-9]{6}/); }); }); diff --git a/packages/ide/test/net.test.ts b/packages/ide/test/net.test.ts index fd20883..964b4ff 100644 --- a/packages/ide/test/net.test.ts +++ b/packages/ide/test/net.test.ts @@ -12,10 +12,17 @@ const net = require("../src/fill/net") as typeof import("net"); describe("net", () => { let i = 0; - const coderDir = path.join(os.tmpdir(), "coder"); + const coderDir = path.join(os.tmpdir(), "coder", "net"); const tmpFile = (): string => path.join(coderDir, `socket.${i++}`); beforeAll(async () => { + try { + await util.promisify(fs.mkdir)(path.dirname(coderDir)); + } catch (error) { + if (error.code !== "EEXIST") { + throw error; + } + } await util.promisify(rimraf)(coderDir); await util.promisify(fs.mkdir)(coderDir); }); diff --git a/packages/protocol/src/browser/client.ts b/packages/protocol/src/browser/client.ts index d436057..ff621a7 100644 --- a/packages/protocol/src/browser/client.ts +++ b/packages/protocol/src/browser/client.ts @@ -4,7 +4,7 @@ import { logger, field } from "@coder/logger"; import { ReadWriteConnection, InitData, OperatingSystem, SharedProcessData } from "../common/connection"; import { Disposer, stringify, parse } from "../common/util"; import { NewEvalMessage, ServerMessage, EvalDoneMessage, EvalFailedMessage, ClientMessage, WorkingInitMessage, EvalEventMessage } from "../proto"; -import { ActiveEval } from "./command"; +import { ActiveEval } from "./evaluate"; /** * Client accepts an arbitrary connection intended to communicate with the Server. diff --git a/packages/protocol/src/node/evaluate.ts b/packages/protocol/src/node/evaluate.ts index fa441be..4e9088e 100644 --- a/packages/protocol/src/node/evaluate.ts +++ b/packages/protocol/src/node/evaluate.ts @@ -12,11 +12,6 @@ export interface ActiveEvaluation { declare var __non_webpack_require__: typeof require; export const evaluate = (connection: SendableConnection, message: NewEvalMessage, onDispose: () => void): ActiveEvaluation | void => { - const argStr: string[] = []; - message.getArgsList().forEach((value) => { - argStr.push(value); - }); - /** * Send the response and call onDispose. */ @@ -94,11 +89,12 @@ export const evaluate = (connection: SendableConnection, message: NewEvalMessage process: { env: process.env, }, + args: message.getArgsList().map(parse), }; let value: any; // tslint:disable-line no-any try { - const code = `(${message.getFunction()})(${eventEmitter ? "eventEmitter, " : ""}${argStr.join(",")});`; + const code = `(${message.getFunction()})(${eventEmitter ? "eventEmitter, " : ""}...args);`; value = vm.runInNewContext(code, sandbox, { // If the code takes longer than this to return, it is killed and throws. timeout: message.getTimeout() || 15000,