mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
esm - some 💄
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/* eslint-disable local/code-import-patterns */
|
||||
|
||||
// Delete `VSCODE_CWD` very early. We have seen
|
||||
// reports where `code .` would use the wrong
|
||||
// current working directory due to our variable
|
||||
|
||||
@@ -36,16 +36,15 @@ if (process.env['ELECTRON_RUN_AS_NODE'] || process.versions['electron']) {
|
||||
register(`data:text/javascript;base64,${Buffer.from(jsCode).toString('base64')}`, import.meta.url);
|
||||
}
|
||||
|
||||
// Prepare globals that are needed for running
|
||||
globalThis._VSCODE_PRODUCT_JSON = { ...product };
|
||||
if (process.env['VSCODE_DEV']) {
|
||||
// Patch product overrides when running out of sources
|
||||
try {
|
||||
const overrides = require('../product.overrides.json');
|
||||
globalThis._VSCODE_PRODUCT_JSON = Object.assign(globalThis._VSCODE_PRODUCT_JSON, overrides);
|
||||
} catch (error) { /* ignore */ }
|
||||
}
|
||||
globalThis._VSCODE_PACKAGE_JSON = { ...pkg };
|
||||
|
||||
globalThis._VSCODE_FILE_ROOT = __dirname;
|
||||
|
||||
//#region NLS helpers
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* eslint-disable local/code-import-patterns */
|
||||
|
||||
import { createRequire } from 'node:module';
|
||||
import { IProductConfiguration } from './vs/base/common/product.js';
|
||||
import type { IProductConfiguration } from './vs/base/common/product.js';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { createRequire } from 'node:module';
|
||||
import { IProductConfiguration } from './vs/base/common/product';
|
||||
import type { IProductConfiguration } from './vs/base/common/product';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
@@ -93,8 +93,10 @@ export function removeGlobalNodeJsModuleLookupPaths(): void {
|
||||
while (commonSuffixLength < paths.length && paths[paths.length - 1 - commonSuffixLength] === globalPaths[globalPaths.length - 1 - commonSuffixLength]) {
|
||||
commonSuffixLength++;
|
||||
}
|
||||
|
||||
return paths.slice(0, paths.length - commonSuffixLength);
|
||||
}
|
||||
|
||||
return paths;
|
||||
};
|
||||
}
|
||||
@@ -105,7 +107,7 @@ export function removeGlobalNodeJsModuleLookupPaths(): void {
|
||||
export function configurePortable(product: Partial<IProductConfiguration>): { portableDataPath: string; isPortable: boolean } {
|
||||
const appRoot = path.dirname(__dirname);
|
||||
|
||||
function getApplicationPath() {
|
||||
function getApplicationPath(): string {
|
||||
if (process.env['VSCODE_DEV']) {
|
||||
return appRoot;
|
||||
}
|
||||
@@ -117,7 +119,7 @@ export function configurePortable(product: Partial<IProductConfiguration>): { po
|
||||
return path.dirname(path.dirname(appRoot));
|
||||
}
|
||||
|
||||
function getPortableDataPath() {
|
||||
function getPortableDataPath(): string {
|
||||
if (process.env['VSCODE_PORTABLE']) {
|
||||
return process.env['VSCODE_PORTABLE'];
|
||||
}
|
||||
|
||||
+5
-5
@@ -8,8 +8,8 @@
|
||||
import * as path from 'path';
|
||||
import * as fs from 'original-fs';
|
||||
import * as os from 'os';
|
||||
import * as bootstrapNode from './bootstrap-node.js';
|
||||
import * as bootstrapESM from './bootstrap-esm.js';
|
||||
import { configurePortable } from './bootstrap-node.js';
|
||||
import { load } from './bootstrap-esm.js';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { app, protocol, crashReporter, Menu, contentTracing } from 'electron';
|
||||
import minimist from 'minimist';
|
||||
@@ -27,7 +27,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
perf.mark('code/didStartMain');
|
||||
|
||||
// Enable portable support
|
||||
const portable = bootstrapNode.configurePortable(product);
|
||||
const portable = configurePortable(product);
|
||||
|
||||
const args = parseCLIArgs();
|
||||
// Configure static command line arguments
|
||||
@@ -176,7 +176,7 @@ function startup(codeCachePath: string | undefined, nlsConfig: INLSConfiguration
|
||||
process.env['VSCODE_CODE_CACHE_PATH'] = codeCachePath || '';
|
||||
|
||||
perf.mark('code/willLoadMainBundle');
|
||||
bootstrapESM.load('vs/code/electron-main/main', () => {
|
||||
load('vs/code/electron-main/main', () => {
|
||||
perf.mark('code/didLoadMainBundle');
|
||||
});
|
||||
}
|
||||
@@ -232,7 +232,7 @@ function configureCommandlineSwitchesSync(cliArgs: NativeParsedArgs) {
|
||||
} else {
|
||||
app.commandLine.appendSwitch(argvKey);
|
||||
}
|
||||
} else if (typeof argvValue === 'string') {
|
||||
} else if (typeof argvValue === 'string' && argvValue) {
|
||||
if (argvKey === 'password-store') {
|
||||
// Password store
|
||||
// TODO@TylerLeonhardt: Remove this migration in 3 months
|
||||
|
||||
+1
-1
@@ -257,7 +257,7 @@ function loadCode(nlsConfiguration: INLSConfiguration): Promise<typeof import('.
|
||||
});
|
||||
}
|
||||
|
||||
function hasStdinWithoutTty() {
|
||||
function hasStdinWithoutTty(): boolean {
|
||||
try {
|
||||
return !process.stdin.isTTY; // Via https://twitter.com/MylesBorins/status/782009479382626304
|
||||
} catch (error) {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import * as perf from '../common/performance.js';
|
||||
import { ILanguagePacks, INLSConfiguration } from '../../nls.js';
|
||||
import type { ILanguagePacks, INLSConfiguration } from '../../nls.js';
|
||||
|
||||
export interface IResolveNLSConfigurationContext {
|
||||
|
||||
@@ -226,6 +226,7 @@ async function exists(path: string): Promise<boolean> {
|
||||
|
||||
function touch(path: string): Promise<void> {
|
||||
const date = new Date();
|
||||
|
||||
return fs.promises.utimes(path, date, date);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user