Skip to content

Commit ed9cdf5

Browse files
Tyriardbaeumer
authored andcommitted
Fork terminalProcess using amd, convert to TS
Fixes #27182
1 parent e027726 commit ed9cdf5

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

src/vs/workbench/buildfile.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ exports.collectModules = function (excludes) {
2525
createModuleDescription('vs/workbench/services/search/node/worker/searchWorkerApp', []),
2626
createModuleDescription('vs/workbench/services/files/node/watcher/unix/watcherApp', []),
2727

28-
createModuleDescription('vs/workbench/node/extensionHostProcess', [])
28+
createModuleDescription('vs/workbench/node/extensionHostProcess', []),
29+
30+
createModuleDescription('vs/workbench/parts/terminal/node/terminalProcess', [])
2931
];
3032

3133
return modules;

src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,8 @@ export class TerminalInstance implements ITerminalInstance {
473473
}
474474
const env = TerminalInstance.createTerminalEnv(process.env, shell, this._getCwd(shell, workspace), locale, this._cols, this._rows);
475475
this._title = shell.name || '';
476-
this._process = cp.fork('../node/terminalProcess', [], {
477-
env: env,
476+
this._process = cp.fork(URI.parse(require.toUrl('bootstrap')).fsPath, ['--type=terminal'], {
477+
env,
478478
cwd: URI.parse(path.dirname(require.toUrl('../node/terminalProcess'))).fsPath
479479
});
480480
if (!shell.name) {
@@ -622,6 +622,7 @@ export class TerminalInstance implements ITerminalInstance {
622622
env['PTYCOLS'] = cols.toString();
623623
env['PTYROWS'] = rows.toString();
624624
}
625+
env['AMD_ENTRYPOINT'] = 'vs/workbench/parts/terminal/node/terminalProcess';
625626
return env;
626627
}
627628

src/vs/workbench/parts/terminal/node/terminalProcess.js renamed to src/vs/workbench/parts/terminal/node/terminalProcess.ts

+24-11
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,23 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
var fs = require('fs');
7-
var os = require('os');
8-
var path = require('path');
9-
var ptyJs = require('node-pty');
6+
import * as fs from 'fs';
7+
fs.writeFileSync('/home/daniel/testing-terminal-1', 'foo');
108

9+
import * as os from 'os';
10+
import * as path from 'path';
11+
import * as ptyJs from 'node-pty';
12+
13+
fs.writeFileSync('/home/daniel/testing-terminal-2', 'foo');
1114
// The pty process needs to be run in its own child process to get around maxing out CPU on Mac,
1215
// see https://github.com/electron/electron/issues/38
13-
14-
var name;
16+
var shellName: string;
1517
if (os.platform() === 'win32') {
16-
name = path.basename(process.env.PTYSHELL);
18+
shellName = path.basename(process.env.PTYSHELL);
1719
} else {
1820
// Using 'xterm-256color' here helps ensure that the majority of Linux distributions will use a
1921
// color prompt as defined in the default ~/.bashrc file.
20-
name = 'xterm-256color';
22+
shellName = 'xterm-256color';
2123
}
2224
var shell = process.env.PTYSHELL;
2325
var args = getArgs();
@@ -29,16 +31,26 @@ var currentTitle = '';
2931
setupPlanB(process.env.PTYPID);
3032
cleanEnv();
3133

32-
var options = {
33-
name: name,
34-
cwd: cwd
34+
interface IOptions {
35+
name: string;
36+
cwd: string;
37+
cols?: number;
38+
rows?: number;
39+
}
40+
41+
var options: IOptions = {
42+
name: shellName,
43+
cwd
3544
};
3645
if (cols && rows) {
3746
options.cols = parseInt(cols, 10);
3847
options.rows = parseInt(rows, 10);
3948
}
4049

50+
fs.writeFileSync('/home/daniel/testing-terminal-3', 'foo');
4151
var ptyProcess = ptyJs.fork(shell, args, options);
52+
53+
fs.writeFileSync('/home/daniel/testing-terminal-4', 'foo');
4254
var closeTimeout;
4355
var exitCode;
4456

@@ -93,6 +105,7 @@ function getArgs() {
93105

94106
function cleanEnv() {
95107
var keys = [
108+
'AMD_ENTRYPOINT',
96109
'ELECTRON_RUN_AS_NODE',
97110
'PTYCWD',
98111
'PTYPID',

0 commit comments

Comments
 (0)