Skip to content

Commit 99b155c

Browse files
authored
cherry-pick(release-1.7): make launch doctor to warn on Win7 (#4719)
PR #4718 SHA b09e0d0
1 parent 4d7fb28 commit 99b155c

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

src/server/validateDependencies.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ export async function validateHostRequirements(browserPath: string, browser: Bro
3131
const ubuntuVersion = await getUbuntuVersion();
3232
if (browser.name === 'firefox' && ubuntuVersion === '16.04')
3333
throw new Error(`Cannot launch firefox on Ubuntu 16.04! Minimum required Ubuntu version for Firefox browser is 18.04`);
34-
await validateDependencies(browserPath, browser);
34+
if (os.platform() === 'linux')
35+
return await validateDependenciesLinux(browserPath, browser);
36+
if (os.platform() === 'win32' && os.arch() === 'x64')
37+
return await validateDependenciesWindows(browserPath, browser);
3538
}
3639

3740
const DL_OPEN_LIBRARIES = {
@@ -41,12 +44,14 @@ const DL_OPEN_LIBRARIES = {
4144
clank: [],
4245
};
4346

44-
async function validateDependencies(browserPath: string, browser: BrowserDescriptor) {
45-
// We currently only support Linux.
46-
if (os.platform() === 'linux')
47-
return await validateDependenciesLinux(browserPath, browser);
48-
if (os.platform() === 'win32' && os.arch() === 'x64')
49-
return await validateDependenciesWindows(browserPath, browser);
47+
function isSupportedWindowsVersion(): boolean {
48+
if (os.platform() !== 'win32' || os.arch() !== 'x64')
49+
return false;
50+
const [major, minor] = os.release().split('.').map(token => parseInt(token, 10));
51+
// This is based on: https://stackoverflow.com/questions/42524606/how-to-get-windows-version-using-node-js/44916050#44916050
52+
// The table with versions is taken from: https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-osversioninfoexw#remarks
53+
// Windows 7 is not supported and is encoded as `6.1`.
54+
return major > 6 || (major === 6 && minor > 1);
5055
}
5156

5257
async function validateDependenciesWindows(browserPath: string, browser: BrowserDescriptor) {
@@ -101,7 +106,13 @@ async function validateDependenciesWindows(browserPath: string, browser: Browser
101106
` ${[...missingDeps].join('\n ')}`,
102107
``);
103108

104-
throw new Error(`Host system is missing dependencies!\n\n${details.join('\n')}`);
109+
const message = `Host system is missing dependencies!\n\n${details.join('\n')}`;
110+
if (isSupportedWindowsVersion()) {
111+
throw new Error(message);
112+
} else {
113+
console.warn(`WARNING: running on unsupported windows version!`);
114+
console.warn(message);
115+
}
105116
}
106117

107118
async function validateDependenciesLinux(browserPath: string, browser: BrowserDescriptor) {

0 commit comments

Comments
 (0)