@@ -18,8 +18,8 @@ Index: code-server/lib/vscode/src/vs/workbench/api/node/extHostExtensionService.
18
18
* Licensed under the MIT License. See License.txt in the project root for license information.
19
19
*--------------------------------------------------------------------------------------------*/
20
20
-
21
- + import { promises as fs } from 'fs ';
22
- + import * as os from 'os'
21
+ + import * as os from 'os ';
22
+ + import * as _http from 'http';
23
23
+ import * as path from 'vs/base/common/path';
24
24
import * as performance from 'vs/base/common/performance';
25
25
import { createApiFactoryAndRegisterActors } from 'vs/workbench/api/common/extHost.api.impl';
@@ -32,12 +32,12 @@ Index: code-server/lib/vscode/src/vs/workbench/api/node/extHostExtensionService.
32
32
33
33
class NodeModuleRequireInterceptor extends RequireInterceptor {
34
34
35
- @@ -79,6 +82,24 @@ export class ExtHostExtensionService ext
35
+ @@ -79,6 +82,59 @@ export class ExtHostExtensionService ext
36
36
await interceptor.install();
37
37
performance.mark('code/extHost/didInitAPI');
38
38
39
39
+ (async () => {
40
- + let socketPath = process.env['VSCODE_IPC_HOOK_CLI'];
40
+ + const socketPath = process.env['VSCODE_IPC_HOOK_CLI'];
41
41
+ if (!socketPath) {
42
42
+ return;
43
43
+ }
@@ -49,7 +49,42 @@ Index: code-server/lib/vscode/src/vs/workbench/api/node/extHostExtensionService.
49
49
+ workspace,
50
50
+ socketPath
51
51
+ };
52
- + fs.appendFile(path.join(os.tmpdir(), 'vscode-ipc'), '\n' + JSON.stringify(entry), 'utf-8');
52
+ + const message = JSON.stringify({entry});
53
+ + const codeServerSocketPath = path.join(os.tmpdir(), 'code-server-ipc.sock');
54
+ + await new Promise<void>((resolve, reject) => {
55
+ + const opts: _http.RequestOptions = {
56
+ + path: '/session',
57
+ + socketPath: codeServerSocketPath,
58
+ + method: 'POST',
59
+ + headers: {
60
+ + 'content-type': 'application/json',
61
+ + 'accept': 'application/json'
62
+ + }
63
+ + };
64
+ + const req = _http.request(opts, (res) => {
65
+ + if (res.headers['content-type'] !== 'application/json') {
66
+ + reject('Error in response: Invalid content type: Expected \'application/json\', is: ' + res.headers['content-type']);
67
+ + return;
68
+ + }
69
+ +
70
+ + res.setEncoding('utf8');
71
+ + res.on('error', reject);
72
+ + res.on('end', () => {
73
+ + try {
74
+ + if (res.statusCode === 200) {
75
+ + resolve();
76
+ + } else {
77
+ + reject(new Error('Unexpected status code: ' + res.statusCode));
78
+ + }
79
+ + } catch (e: unknown) {
80
+ + reject(e);
81
+ + }
82
+ + });
83
+ + });
84
+ + req.on('error', reject);
85
+ + req.write(message);
86
+ + req.end();
87
+ + });
53
88
+ })().catch(error => {
54
89
+ this._logService.error(error);
55
90
+ });
0 commit comments