fix: use win64 version of chromium when on arm64 windows (#8927)

* fix: use win64 version of chromium when on arm64 windows

no Win_arm available on storage.googleapis.com yet, and it currently defaults to win32

* fix: lint trailing space

* fix: use x64 chromium on Windows 11 for ARM

* fix: detect windows 11 without semver
This commit is contained in:
robrobrobrob 2022-09-19 00:24:34 -07:00 committed by GitHub
parent 6f37eed91b
commit 64843b8885
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -237,7 +237,12 @@ export class BrowserFetcher {
this.#platform = 'linux';
break;
case 'win32':
this.#platform = os.arch() === 'x64' ? 'win64' : 'win32';
this.#platform =
os.arch() === 'x64' ||
// Windows 11 for ARM supports x64 emulation
(os.arch() === 'arm64' && _isWindows11(os.release()))
? 'win64'
: 'win32';
return;
default:
assert(false, 'Unsupported platform: ' + platform);
@ -497,6 +502,25 @@ function parseFolderPath(
return {product, platform, revision};
}
/**
* Windows 11 is identified by 10.0.22000 or greater
* @internal
*/
function _isWindows11(version: string): boolean {
const parts = version.split('.');
if (parts.length > 2) {
const major = parseInt(parts[0] as string, 10);
const minor = parseInt(parts[1] as string, 10);
const patch = parseInt(parts[2] as string, 10);
return (
major > 10 ||
(major === 10 && minor > 0) ||
(major === 10 && minor === 0 && patch >= 22000)
);
}
return false;
}
/**
* @internal
*/