mirror of
https://github.com/coder/code-server.git
synced 2026-05-27 06:37:27 +02:00
chore(vscode): update to 1.54.2
This commit is contained in:
@@ -8,18 +8,72 @@ import * as os from 'os';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import { env } from 'vs/base/common/process';
|
||||
|
||||
const WindowsPowerShell64BitLabel = 'Windows PowerShell';
|
||||
const WindowsPowerShell32BitLabel = 'Windows PowerShell (x86)';
|
||||
|
||||
// This is required, since parseInt("7-preview") will return 7.
|
||||
const IntRegex: RegExp = /^\d+$/;
|
||||
|
||||
const PwshMsixRegex: RegExp = /^Microsoft.PowerShell_.*/;
|
||||
const PwshPreviewMsixRegex: RegExp = /^Microsoft.PowerShellPreview_.*/;
|
||||
|
||||
// The platform details descriptor for the platform we're on
|
||||
const isProcess64Bit: boolean = process.arch === 'x64';
|
||||
const isOS64Bit: boolean = isProcess64Bit || os.arch() === 'x64';
|
||||
const enum Arch {
|
||||
x64,
|
||||
x86,
|
||||
ARM
|
||||
}
|
||||
|
||||
let processArch: Arch;
|
||||
switch (process.arch) {
|
||||
case 'ia32':
|
||||
case 'x32':
|
||||
processArch = Arch.x86;
|
||||
break;
|
||||
case 'arm':
|
||||
case 'arm64':
|
||||
processArch = Arch.ARM;
|
||||
break;
|
||||
default:
|
||||
processArch = Arch.x64;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
Currently, here are the values for these environment variables on their respective archs:
|
||||
|
||||
On x86 process on x86:
|
||||
PROCESSOR_ARCHITECTURE is X86
|
||||
PROCESSOR_ARCHITEW6432 is undefined
|
||||
|
||||
On x86 process on x64:
|
||||
PROCESSOR_ARCHITECTURE is X86
|
||||
PROCESSOR_ARCHITEW6432 is AMD64
|
||||
|
||||
On x64 process on x64:
|
||||
PROCESSOR_ARCHITECTURE is AMD64
|
||||
PROCESSOR_ARCHITEW6432 is undefined
|
||||
|
||||
On ARM process on ARM:
|
||||
PROCESSOR_ARCHITECTURE is ARM64
|
||||
PROCESSOR_ARCHITEW6432 is undefined
|
||||
|
||||
On x86 process on ARM:
|
||||
PROCESSOR_ARCHITECTURE is X86
|
||||
PROCESSOR_ARCHITEW6432 is ARM64
|
||||
|
||||
On x64 process on ARM:
|
||||
PROCESSOR_ARCHITECTURE is ARM64
|
||||
PROCESSOR_ARCHITEW6432 is undefined
|
||||
*/
|
||||
let osArch: Arch;
|
||||
if (process.env['PROCESSOR_ARCHITEW6432']) {
|
||||
osArch = process.env['PROCESSOR_ARCHITEW6432'] === 'ARM64'
|
||||
? Arch.ARM
|
||||
: Arch.x64;
|
||||
} else if (process.env['PROCESSOR_ARCHITECTURE'] === 'ARM64') {
|
||||
osArch = Arch.ARM;
|
||||
} else if (process.env['PROCESSOR_ARCHITECTURE'] === 'X86') {
|
||||
osArch = Arch.x86;
|
||||
} else {
|
||||
osArch = Arch.x64;
|
||||
}
|
||||
|
||||
export interface IPowerShellExeDetails {
|
||||
readonly displayName: string;
|
||||
@@ -38,7 +92,7 @@ class PossiblePowerShellExe implements IPossiblePowerShellExe {
|
||||
|
||||
public async exists(): Promise<boolean> {
|
||||
if (this.knownToExist === undefined) {
|
||||
this.knownToExist = await pfs.fileExists(this.exePath);
|
||||
this.knownToExist = await pfs.SymlinkSupport.existsFile(this.exePath);
|
||||
}
|
||||
return this.knownToExist;
|
||||
}
|
||||
@@ -53,12 +107,12 @@ function getProgramFilesPath(
|
||||
}
|
||||
|
||||
// We might be a 64-bit process looking for 32-bit program files
|
||||
if (isProcess64Bit) {
|
||||
if (processArch === Arch.x64) {
|
||||
return env['ProgramFiles(x86)'] || null;
|
||||
}
|
||||
|
||||
// We might be a 32-bit process looking for 64-bit program files
|
||||
if (isOS64Bit) {
|
||||
if (osArch === Arch.x64) {
|
||||
return env.ProgramW6432 || null;
|
||||
}
|
||||
|
||||
@@ -66,28 +120,6 @@ function getProgramFilesPath(
|
||||
return null;
|
||||
}
|
||||
|
||||
function getSystem32Path({ useAlternateBitness = false }: { useAlternateBitness?: boolean } = {}): string {
|
||||
const windir: string = env.windir!;
|
||||
|
||||
if (!useAlternateBitness) {
|
||||
// Just use the native system bitness
|
||||
return path.join(windir, 'System32');
|
||||
}
|
||||
|
||||
// We might be a 64-bit process looking for 32-bit system32
|
||||
if (isProcess64Bit) {
|
||||
return path.join(windir, 'SysWOW64');
|
||||
}
|
||||
|
||||
// We might be a 32-bit process looking for 64-bit system32
|
||||
if (isOS64Bit) {
|
||||
return path.join(windir, 'Sysnative');
|
||||
}
|
||||
|
||||
// We're on a 32-bit Windows, so no alternate bitness
|
||||
return path.join(windir, 'System32');
|
||||
}
|
||||
|
||||
async function findPSCoreWindowsInstallation(
|
||||
{ useAlternateBitness = false, findPreview = false }:
|
||||
{ useAlternateBitness?: boolean; findPreview?: boolean } = {}): Promise<IPossiblePowerShellExe | null> {
|
||||
@@ -100,7 +132,7 @@ async function findPSCoreWindowsInstallation(
|
||||
const powerShellInstallBaseDir = path.join(programFilesPath, 'PowerShell');
|
||||
|
||||
// Ensure the base directory exists
|
||||
if (!await pfs.dirExists(powerShellInstallBaseDir)) {
|
||||
if (!await pfs.SymlinkSupport.existsDirectory(powerShellInstallBaseDir)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -142,7 +174,7 @@ async function findPSCoreWindowsInstallation(
|
||||
|
||||
// Now look for the file
|
||||
const exePath = path.join(powerShellInstallBaseDir, item, 'pwsh.exe');
|
||||
if (!await pfs.fileExists(exePath)) {
|
||||
if (!await pfs.SymlinkSupport.existsFile(exePath)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -169,7 +201,7 @@ async function findPSCoreMsix({ findPreview }: { findPreview?: boolean } = {}):
|
||||
// Find the base directory for MSIX application exe shortcuts
|
||||
const msixAppDir = path.join(env.LOCALAPPDATA, 'Microsoft', 'WindowsApps');
|
||||
|
||||
if (!await pfs.dirExists(msixAppDir)) {
|
||||
if (!await pfs.SymlinkSupport.existsDirectory(msixAppDir)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -179,11 +211,15 @@ async function findPSCoreMsix({ findPreview }: { findPreview?: boolean } = {}):
|
||||
: { pwshMsixDirRegex: PwshMsixRegex, pwshMsixName: 'PowerShell (Store)' };
|
||||
|
||||
// We should find only one such application, so return on the first one
|
||||
for (const subdir of await pfs.readdir(msixAppDir)) {
|
||||
if (pwshMsixDirRegex.test(subdir)) {
|
||||
const pwshMsixPath = path.join(msixAppDir, subdir, 'pwsh.exe');
|
||||
return new PossiblePowerShellExe(pwshMsixPath, pwshMsixName);
|
||||
try {
|
||||
for (const subdir of await pfs.readdir(msixAppDir)) {
|
||||
if (pwshMsixDirRegex.test(subdir)) {
|
||||
const pwshMsixPath = path.join(msixAppDir, subdir, 'pwsh.exe');
|
||||
return new PossiblePowerShellExe(pwshMsixPath, pwshMsixName);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn(`Unable to read MSIX directory (${msixAppDir}) because of the following error: ${err}`);
|
||||
}
|
||||
|
||||
// If we find nothing, return null
|
||||
@@ -196,33 +232,13 @@ function findPSCoreDotnetGlobalTool(): IPossiblePowerShellExe {
|
||||
return new PossiblePowerShellExe(dotnetGlobalToolExePath, '.NET Core PowerShell Global Tool');
|
||||
}
|
||||
|
||||
function findWinPS({ useAlternateBitness = false }: { useAlternateBitness?: boolean } = {}): IPossiblePowerShellExe | null {
|
||||
function findWinPS(): IPossiblePowerShellExe | null {
|
||||
const winPSPath = path.join(
|
||||
env.windir!,
|
||||
processArch === Arch.x86 && osArch !== Arch.x86 ? 'SysNative' : 'System32',
|
||||
'WindowsPowerShell', 'v1.0', 'powershell.exe');
|
||||
|
||||
// x86 and ARM only have one WinPS on them
|
||||
if (!isOS64Bit && useAlternateBitness) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const systemFolderPath = getSystem32Path({ useAlternateBitness });
|
||||
|
||||
const winPSPath = path.join(systemFolderPath, 'WindowsPowerShell', 'v1.0', 'powershell.exe');
|
||||
|
||||
let displayName: string;
|
||||
if (isProcess64Bit) {
|
||||
displayName = useAlternateBitness
|
||||
? WindowsPowerShell32BitLabel
|
||||
: WindowsPowerShell64BitLabel;
|
||||
} else if (isOS64Bit) {
|
||||
displayName = useAlternateBitness
|
||||
? WindowsPowerShell64BitLabel
|
||||
: WindowsPowerShell32BitLabel;
|
||||
} else {
|
||||
// NOTE: ARM Windows devices also have Windows PowerShell x86 on them. There is no
|
||||
// "ARM Windows PowerShell".
|
||||
displayName = WindowsPowerShell32BitLabel;
|
||||
}
|
||||
|
||||
return new PossiblePowerShellExe(winPSPath, displayName, true);
|
||||
return new PossiblePowerShellExe(winPSPath, 'Windows PowerShell', true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -276,18 +292,10 @@ async function* enumerateDefaultPowerShellInstallations(): AsyncIterable<IPossib
|
||||
}
|
||||
|
||||
// Finally, get Windows PowerShell
|
||||
|
||||
// Get the natural Windows PowerShell for the process bitness
|
||||
pwshExe = findWinPS();
|
||||
if (pwshExe) {
|
||||
yield pwshExe;
|
||||
}
|
||||
|
||||
// Get the alternate bitness Windows PowerShell
|
||||
pwshExe = findWinPS({ useAlternateBitness: true });
|
||||
if (pwshExe) {
|
||||
yield pwshExe;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user