diff --git a/src/bootstrap-cli.ts b/src/bootstrap-cli.ts index 68985e69dff..f454b830ea6 100644 --- a/src/bootstrap-cli.ts +++ b/src/bootstrap-cli.ts @@ -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 diff --git a/src/bootstrap-esm.ts b/src/bootstrap-esm.ts index 0b7e8b48145..b0c6d142a4f 100644 --- a/src/bootstrap-esm.ts +++ b/src/bootstrap-esm.ts @@ -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 diff --git a/src/bootstrap-meta.ts b/src/bootstrap-meta.ts index b8a163d277e..c17716c8d31 100644 --- a/src/bootstrap-meta.ts +++ b/src/bootstrap-meta.ts @@ -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); diff --git a/src/bootstrap-node.ts b/src/bootstrap-node.ts index e770cedcc46..0fc29f14d2c 100644 --- a/src/bootstrap-node.ts +++ b/src/bootstrap-node.ts @@ -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): { 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): { po return path.dirname(path.dirname(appRoot)); } - function getPortableDataPath() { + function getPortableDataPath(): string { if (process.env['VSCODE_PORTABLE']) { return process.env['VSCODE_PORTABLE']; } diff --git a/src/main.ts b/src/main.ts index 9d4cff34d76..2138298e3b8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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 diff --git a/src/server-main.ts b/src/server-main.ts index 4a30c8860ed..79439bdfc4b 100644 --- a/src/server-main.ts +++ b/src/server-main.ts @@ -257,7 +257,7 @@ function loadCode(nlsConfiguration: INLSConfiguration): Promise { function touch(path: string): Promise { const date = new Date(); + return fs.promises.utimes(path, date, date); }