Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions extensions/typescript/src/typescriptServiceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -599,10 +599,6 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
}

private get mainWorkspaceRootPath(): string | undefined {
if (workspace.rootPath) {
return workspace.rootPath;
}

if (workspace.workspaceFolders && workspace.workspaceFolders.length) {
return workspace.workspaceFolders[0].uri.fsPath;
}
Expand Down
30 changes: 17 additions & 13 deletions extensions/typescript/src/utils/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function makeRandomHexString(length: number): string {
let chars = ['0', '1', '2', '3', '4', '5', '6', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
let result = '';
for (let i = 0; i < length; i++) {
let idx = Math.floor(chars.length * Math.random());
const idx = Math.floor(chars.length * Math.random());
result += chars[idx];
}
return result;
Expand All @@ -27,6 +27,7 @@ export function makeRandomHexString(length: number): string {
function generatePipeName(): string {
return getPipeName(makeRandomHexString(40));
}

function getPipeName(name: string): string {
const fullName = 'vscode-' + name;
if (process.platform === 'win32') {
Expand All @@ -43,19 +44,22 @@ export function getTempFile(name: string): string {
}


function generatePatchedEnv(env: any, stdInPipeName: string, stdOutPipeName: string, stdErrPipeName: string): any {
// Set the two unique pipe names and the electron flag as process env

var newEnv: any = {};
for (var key in env) {
newEnv[key] = env[key];
}
function generatePatchedEnv(
env: any,
stdInPipeName: string,
stdOutPipeName: string,
stdErrPipeName: string
): any {
const newEnv = Object.assign({}, env);

// Set the two unique pipe names and the electron flag as process env
newEnv['STDIN_PIPE_NAME'] = stdInPipeName;
newEnv['STDOUT_PIPE_NAME'] = stdOutPipeName;
newEnv['STDERR_PIPE_NAME'] = stdErrPipeName;
newEnv['ELECTRON_RUN_AS_NODE'] = '1';

// Ensure we always have a PATH set
newEnv['PATH'] = newEnv['PATH'] || process.env.PATH;
return newEnv;
}

Expand All @@ -67,7 +71,7 @@ export function fork(
callback: (error: any, cp: cp.ChildProcess | null) => void,
): void {

var callbackCalled = false;
let callbackCalled = false;
const resolve = (result: cp.ChildProcess) => {
if (callbackCalled) {
return;
Expand All @@ -90,7 +94,7 @@ export function fork(


const newEnv = generatePatchedEnv(process.env, stdInPipeName, stdOutPipeName, stdErrPipeName);
var childProcess: cp.ChildProcess;
let childProcess: cp.ChildProcess;

// Begin listening to stderr pipe
let stdErrServer = net.createServer((stdErrStream) => {
Expand All @@ -115,7 +119,7 @@ export function fork(
});
stdOutServer.listen(stdOutPipeName);

var serverClosed = false;
let serverClosed = false;
const closeServer = () => {
if (serverClosed) {
return;
Expand All @@ -128,8 +132,8 @@ export function fork(
// Create the process
logger.info('Forking TSServer', `PATH: ${newEnv['PATH']}`);

const bootstrapperPath = path.join(__dirname, 'electronForkStart');
childProcess = cp.fork(bootstrapperPath, [modulePath].concat(args), <any>{
const bootstrapperPath = require.resolve('./electronForkStart');
childProcess = cp.fork(bootstrapperPath, [modulePath].concat(args), {
silent: true,
cwd: options.cwd,
env: newEnv,
Expand Down