mirror of https://github.com/coder/code-server.git
Fix debugging
This commit is contained in:
parent
277c6cb690
commit
2169045377
|
@ -1,19 +1,19 @@
|
||||||
import * as fse from "fs-extra";
|
|
||||||
import { field, logger } from "@coder/logger";
|
import { field, logger } from "@coder/logger";
|
||||||
import { ServerMessage, SharedProcessActiveMessage } from "@coder/protocol/src/proto";
|
import { ServerMessage, SharedProcessActiveMessage } from "@coder/protocol/src/proto";
|
||||||
import { Command, flags } from "@oclif/command";
|
import { Command, flags } from "@oclif/command";
|
||||||
import { fork, ForkOptions, ChildProcess } from "child_process";
|
import { ChildProcess, fork, ForkOptions, spawn } from "child_process";
|
||||||
import { randomFillSync } from "crypto";
|
import { randomFillSync } from "crypto";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
|
import * as fse from "fs-extra";
|
||||||
import * as os from "os";
|
import * as os from "os";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import * as WebSocket from "ws";
|
import * as WebSocket from "ws";
|
||||||
import { createApp } from "./server";
|
import { buildDir, cacheHome, dataHome, isCli, serveStatic } from "./constants";
|
||||||
import { requireModule, requireFork, forkModule } from "./vscode/bootstrapFork";
|
|
||||||
import { SharedProcess, SharedProcessState } from "./vscode/sharedProcess";
|
|
||||||
import { setup as setupNativeModules } from "./modules";
|
|
||||||
import { fillFs } from "./fill";
|
import { fillFs } from "./fill";
|
||||||
import { isCli, serveStatic, buildDir, dataHome, cacheHome } from "./constants";
|
import { setup as setupNativeModules } from "./modules";
|
||||||
|
import { createApp } from "./server";
|
||||||
|
import { forkModule, requireFork, requireModule } from "./vscode/bootstrapFork";
|
||||||
|
import { SharedProcess, SharedProcessState } from "./vscode/sharedProcess";
|
||||||
import opn = require("opn");
|
import opn = require("opn");
|
||||||
|
|
||||||
export class Entry extends Command {
|
export class Entry extends Command {
|
||||||
|
@ -187,7 +187,14 @@ export class Entry extends Command {
|
||||||
return forkModule(options.env.AMD_ENTRYPOINT, args, options, dataDir);
|
return forkModule(options.env.AMD_ENTRYPOINT, args, options, dataDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isCli) {
|
||||||
|
return spawn(process.execPath, ["--fork", modulePath, "--args", JSON.stringify(args), "--data-dir", dataDir], {
|
||||||
|
...options,
|
||||||
|
stdio: [null, null, null, "ipc"],
|
||||||
|
});
|
||||||
|
} else {
|
||||||
return fork(modulePath, args, options);
|
return fork(modulePath, args, options);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
password,
|
password,
|
||||||
|
|
|
@ -46,12 +46,13 @@ export const requireFork = (modulePath: string, args: string[], builtInExtension
|
||||||
const Module = require("module") as typeof import("module");
|
const Module = require("module") as typeof import("module");
|
||||||
const oldRequire = Module.prototype.require;
|
const oldRequire = Module.prototype.require;
|
||||||
// tslint:disable-next-line:no-any
|
// tslint:disable-next-line:no-any
|
||||||
Module.prototype.require = (id: string): any => {
|
Module.prototype.require = function (id: string): any {
|
||||||
if (id === "typescript") {
|
if (id === "typescript") {
|
||||||
return require("typescript");
|
return require("typescript");
|
||||||
}
|
}
|
||||||
|
|
||||||
return oldRequire(id);
|
// tslint:disable-next-line:no-any
|
||||||
|
return oldRequire.call(this, id as any);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!process.send) {
|
if (!process.send) {
|
||||||
|
@ -59,7 +60,6 @@ export const requireFork = (modulePath: string, args: string[], builtInExtension
|
||||||
}
|
}
|
||||||
|
|
||||||
process.argv = ["", "", ...args];
|
process.argv = ["", "", ...args];
|
||||||
|
|
||||||
requireFilesystemModule(modulePath, builtInExtensionsDir);
|
requireFilesystemModule(modulePath, builtInExtensionsDir);
|
||||||
|
|
||||||
if (ipcMsgBuffer && ipcMsgListener) {
|
if (ipcMsgBuffer && ipcMsgListener) {
|
||||||
|
|
Loading…
Reference in New Issue