|
1 |
| -import * as fse from "fs-extra"; |
2 | 1 | import { field, logger } from "@coder/logger";
|
3 | 2 | import { ServerMessage, SharedProcessActiveMessage } from "@coder/protocol/src/proto";
|
4 | 3 | import { Command, flags } from "@oclif/command";
|
5 |
| -import { fork, ForkOptions, ChildProcess } from "child_process"; |
| 4 | +import { ChildProcess, fork, ForkOptions, spawn } from "child_process"; |
6 | 5 | import { randomFillSync } from "crypto";
|
7 | 6 | import * as fs from "fs";
|
| 7 | +import * as fse from "fs-extra"; |
8 | 8 | import * as os from "os";
|
9 | 9 | import * as path from "path";
|
10 | 10 | import * as WebSocket from "ws";
|
| 11 | +import { buildDir, cacheHome, dataHome, isCli, serveStatic } from "./constants"; |
| 12 | +import { fillFs } from "./fill"; |
| 13 | +import { setup as setupNativeModules } from "./modules"; |
11 | 14 | import { createApp } from "./server";
|
12 |
| -import { requireModule, requireFork, forkModule } from "./vscode/bootstrapFork"; |
| 15 | +import { forkModule, requireFork, requireModule } from "./vscode/bootstrapFork"; |
13 | 16 | import { SharedProcess, SharedProcessState } from "./vscode/sharedProcess";
|
14 |
| -import { setup as setupNativeModules } from "./modules"; |
15 |
| -import { fillFs } from "./fill"; |
16 |
| -import { isCli, serveStatic, buildDir, dataHome, cacheHome } from "./constants"; |
17 | 17 | import opn = require("opn");
|
18 | 18 |
|
19 | 19 | export class Entry extends Command {
|
@@ -187,7 +187,14 @@ export class Entry extends Command {
|
187 | 187 | return forkModule(options.env.AMD_ENTRYPOINT, args, options, dataDir);
|
188 | 188 | }
|
189 | 189 |
|
190 |
| - return fork(modulePath, args, options); |
| 190 | + if (isCli) { |
| 191 | + return spawn(process.execPath, ["--fork", modulePath, "--args", JSON.stringify(args), "--data-dir", dataDir], { |
| 192 | + ...options, |
| 193 | + stdio: [null, null, null, "ipc"], |
| 194 | + }); |
| 195 | + } else { |
| 196 | + return fork(modulePath, args, options); |
| 197 | + } |
191 | 198 | },
|
192 | 199 | },
|
193 | 200 | password,
|
|
0 commit comments