Rename files to mark them as browser or electron

This commit is contained in:
Matt Bierner 2020-07-22 00:34:55 -07:00
parent c6ce8f26cc
commit 3b15049759
8 changed files with 55 additions and 67 deletions

View file

@ -11,7 +11,7 @@ import { createLazyClientHost, lazilyActivateClient } from './lazyClientHost';
import { noopRequestCancellerFactory } from './tsServer/cancellation';
import { noopLogDirectoryProvider } from './tsServer/logDirectoryProvider';
import { ITypeScriptVersionProvider, TypeScriptVersion, TypeScriptVersionSource } from './tsServer/versionProvider';
import { WorkerServerProcess } from './tsServer/workerServerProcess';
import { WorkerServerProcess } from './tsServer/serverProcess.browser';
import API from './utils/api';
import { CommandManager } from './utils/commandManager';
import { TypeScriptServiceConfiguration } from './utils/configuration';

View file

@ -11,12 +11,12 @@ import { LanguageConfigurationManager } from './languageFeatures/languageConfigu
import { createLazyClientHost, lazilyActivateClient } from './lazyClientHost';
import { nodeRequestCancellerFactory } from './tsServer/cancellation.electron';
import { NodeLogDirectoryProvider } from './tsServer/logDirectoryProvider.electron';
import { ChildServerProcess } from './tsServer/serverProcess';
import { ChildServerProcess } from './tsServer/serverProcess.electron';
import { DiskTypeScriptVersionProvider } from './tsServer/versionProvider.electron';
import { CommandManager } from './utils/commandManager';
import * as electron from './utils/electron';
import { onCaseInsenitiveFileSystem } from './utils/fileSystem';
import { onCaseInsenitiveFileSystem } from './utils/fileSystem.electron';
import { PluginManager } from './utils/plugins';
import * as temp from './utils/temp.electron';
export function activate(
context: vscode.ExtensionContext
@ -62,5 +62,5 @@ export function activate(
}
export function deactivate() {
rimraf.sync(electron.getInstanceDir());
rimraf.sync(temp.getInstanceTempDir());
}

View file

@ -1,40 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as temp from './temp';
import path = require('path');
import fs = require('fs');
import process = require('process');
const getRootTempDir = (() => {
let dir: string | undefined;
return () => {
if (!dir) {
dir = temp.getTempFile(`vscode-typescript${process.platform !== 'win32' && process.getuid ? process.getuid() : ''}`);
}
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
return dir;
};
})();
export const getInstanceDir = (() => {
let dir: string | undefined;
return () => {
if (!dir) {
dir = path.join(getRootTempDir(), temp.makeRandomHexString(20));
}
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
return dir;
};
})();
export function getTempFile(prefix: string): string {
return path.join(getInstanceDir(), `${prefix}-${temp.makeRandomHexString(20)}.tmp`);
}

View file

@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as fs from 'fs';
import { getTempFile } from '../utils/temp';
import { getTempFile } from './temp.electron';
export const onCaseInsenitiveFileSystem = (() => {
let value: boolean | undefined;

View file

@ -0,0 +1,49 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as os from 'os';
import * as fs from 'fs';
import * as path from 'path';
function makeRandomHexString(length: number): string {
const chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
let result = '';
for (let i = 0; i < length; i++) {
const idx = Math.floor(chars.length * Math.random());
result += chars[idx];
}
return result;
}
const getRootTempDir = (() => {
let dir: string | undefined;
return () => {
if (!dir) {
const filename = `vscode-typescript${process.platform !== 'win32' && process.getuid ? process.getuid() : ''}`;
dir = path.join(os.tmpdir(), filename);
}
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
return dir;
};
})();
export const getInstanceTempDir = (() => {
let dir: string | undefined;
return () => {
if (!dir) {
dir = path.join(getRootTempDir(), makeRandomHexString(20));
}
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
return dir;
};
})();
export function getTempFile(prefix: string): string {
return path.join(getInstanceTempDir(), `${prefix}-${makeRandomHexString(20)}.tmp`);
}

View file

@ -1,21 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import path = require('path');
import os = require('os');
export function makeRandomHexString(length: number): string {
const chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
let result = '';
for (let i = 0; i < length; i++) {
const idx = Math.floor(chars.length * Math.random());
result += chars[idx];
}
return result;
}
export function getTempFile(name: string): string {
return path.join(os.tmpdir(), name);
}