Skip to content

Commit cde3271

Browse files
committed
Remove fork override
1 parent e9c0c96 commit cde3271

File tree

2 files changed

+6
-70
lines changed

2 files changed

+6
-70
lines changed

packages/server/src/cli.ts

+3-18
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import * as path from "path";
99
import * as WebSocket from "ws";
1010
import { buildDir, cacheHome, dataHome, isCli, serveStatic } from "./constants";
1111
import { createApp } from "./server";
12-
import { forkModule, requireFork, requireModule } from "./vscode/bootstrapFork";
12+
import { forkModule, requireModule } from "./vscode/bootstrapFork";
1313
import { SharedProcess, SharedProcessState } from "./vscode/sharedProcess";
1414
import opn = require("opn");
1515

@@ -30,7 +30,6 @@ commander.version(process.env.VERSION || "development")
3030
.option("-H, --allow-http", "Allow http connections.", false)
3131
.option("-P, --password <value>", "Specify a password for authentication.")
3232
.option("--bootstrap-fork <name>", "Used for development. Never set.")
33-
.option("--fork <name>", "Used for development. Never set.")
3433
.option("--extra-args <args>", "Used for development. Never set.")
3534
.arguments("Specify working directory.")
3635
.parse(process.argv);
@@ -62,7 +61,6 @@ const bold = (text: string | number): string | number => {
6261
readonly certKey?: string;
6362

6463
readonly bootstrapFork?: string;
65-
readonly fork?: string;
6664
readonly extraArgs?: string;
6765
};
6866

@@ -119,13 +117,7 @@ const bold = (text: string | number): string | number => {
119117
process.argv[i + 2] = arg;
120118
});
121119

122-
return requireModule(modulePath, dataDir, builtInExtensionsDir);
123-
}
124-
125-
if (options.fork) {
126-
const modulePath = options.fork;
127-
128-
return requireFork(modulePath, JSON.parse(options.extraArgs!), builtInExtensionsDir);
120+
return requireModule(modulePath, builtInExtensionsDir);
129121
}
130122

131123
const logDir = path.join(cacheHome, "code-server/logs", new Date().toISOString().replace(/[-:.TZ]/g, ""));
@@ -231,14 +223,7 @@ const bold = (text: string | number): string | number => {
231223
return forkModule(options.env.AMD_ENTRYPOINT, args, options, dataDir);
232224
}
233225

234-
if (isCli) {
235-
return spawn(process.execPath, [path.join(buildDir, "out", "cli.js"), "--fork", modulePath, "--extra-args", JSON.stringify(args), "--data-dir", dataDir], {
236-
...options,
237-
stdio: [null, null, null, "ipc"],
238-
});
239-
} else {
240-
return fork(modulePath, args, options);
241-
}
226+
return fork(modulePath, args, options);
242227
},
243228
},
244229
password,

packages/server/src/vscode/bootstrapFork.ts

+3-52
Original file line numberDiff line numberDiff line change
@@ -42,54 +42,13 @@ const requireFilesystemModule = (id: string, builtInExtensionsDir: string): any
4242
return customMod.require(id);
4343
};
4444

45-
/**
46-
* Called from forking a module
47-
*/
48-
export const requireFork = (modulePath: string, args: string[], builtInExtensionsDir: string): void => {
49-
const Module = require("module") as typeof import("module");
50-
const oldRequire = Module.prototype.require;
51-
// tslint:disable-next-line:no-any
52-
const oldLoad = (Module as any)._findPath;
53-
// @ts-ignore
54-
(Module as any)._findPath = function (request, parent, isMain): any {
55-
const lookupPaths = oldLoad.call(this, request, parent, isMain);
56-
57-
return lookupPaths;
58-
};
59-
// tslint:disable-next-line:no-any
60-
Module.prototype.require = function (id: string): any {
61-
if (id === "typescript") {
62-
return require("typescript");
63-
}
64-
65-
// tslint:disable-next-line:no-any
66-
return oldRequire.call(this, id as any);
67-
};
68-
69-
if (!process.send) {
70-
throw new Error("No IPC messaging initialized");
71-
}
72-
73-
process.argv = ["", "", ...args];
74-
requireFilesystemModule(modulePath, builtInExtensionsDir);
75-
76-
if (ipcMsgBuffer && ipcMsgListener) {
77-
process.removeListener("message", ipcMsgListener);
78-
// tslint:disable-next-line:no-any
79-
ipcMsgBuffer.forEach((i) => process.emit("message" as any, i as any));
80-
ipcMsgBuffer = undefined;
81-
ipcMsgListener = undefined;
82-
}
83-
};
84-
85-
export const requireModule = (modulePath: string, dataDir: string, builtInExtensionsDir: string): void => {
45+
export const requireModule = (modulePath: string, builtInExtensionsDir: string): void => {
8646
process.env.AMD_ENTRYPOINT = modulePath;
8747
const xml = require("xhr2");
8848
xml.XMLHttpRequest.prototype._restrictedHeaders["user-agent"] = false;
8949
// tslint:disable-next-line no-any this makes installing extensions work.
9050
(global as any).XMLHttpRequest = xml.XMLHttpRequest;
9151

92-
const mod = require("module") as typeof import("module");
9352
const promiseFinally = require("promise.prototype.finally") as { shim: () => void };
9453
promiseFinally.shim();
9554
/**
@@ -102,16 +61,8 @@ export const requireModule = (modulePath: string, dataDir: string, builtInExtens
10261
};
10362

10463
if (isCli) {
105-
/**
106-
* Needed for properly forking external modules within the CLI
107-
*/
108-
// tslint:disable-next-line:no-any
109-
(<any>cp).fork = (modulePath: string, args: ReadonlyArray<string> = [], options?: cp.ForkOptions): cp.ChildProcess => {
110-
return cp.spawn(process.execPath, [path.join(buildDir, "out", "cli.js"), "--fork", modulePath, "--extra-args", JSON.stringify(args), "--data-dir", dataDir], {
111-
...options,
112-
stdio: [null, null, null, "ipc"],
113-
});
114-
};
64+
// Needed for properly forking external modules within the CLI.
65+
process.env.NBIN_BYPASS = "true";
11566
}
11667

11768
const baseDir = path.join(buildDir, "build");

0 commit comments

Comments
 (0)