Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disable downloads for Electron below 6.0.8 and 7.0.0 on Windows arm64 #1050

Merged
merged 1 commit into from
Apr 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/utils/disable-download.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import semver from 'semver';

/**
* disables download button for versions below 11.0.0 on Apple Silicon.
* disables download button for versions:
* - below 11.0.0 on Apple Silicon.
* - below 6.0.8 and 7.0.0 on Windows arm64
* Reference: {@link https://www.electronjs.org/blog/apple-silicon}
*
* @param {string} version - electron version
* @returns {boolean}
*/
export function disableDownload(version: string) {
return (
process.platform === 'darwin' &&
process.arch === 'arm64' &&
semver.lt(version, '11.0.0')
(process.platform === 'darwin' &&
process.arch === 'arm64' &&
semver.lt(version, '11.0.0')) ||
(process.platform === 'win32' &&
process.arch === 'arm64' &&
!semver.satisfies(version, '>=6.0.8 || >=7.0.0'))
);
}
20 changes: 16 additions & 4 deletions tests/utils/disable-download-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,24 @@ describe('disableDownload', () => {
resetArch();
});

it('always return false when the system is windows', () => {
it('always return false when the system is windows and the arch is not arm64', () => {
overridePlatform('win32');
overrideArch('x64');

expect(disableDownload('10.0.0')).toBe(false);
expect(disableDownload('11.0.0')).toBe(false);
expect(disableDownload('12.0.0')).toBe(false);
expect(disableDownload('6.0.0')).toBe(false);
expect(disableDownload('6.0.8')).toBe(false);
expect(disableDownload('7.0.0')).toBe(false);
expect(disableDownload('8.0.0')).toBe(false);
});

it('returns true if the system is windows and the arch is arm64', () => {
overridePlatform('win32');
overrideArch('arm64');

expect(disableDownload('6.0.0')).toBe(true);
expect(disableDownload('6.0.8')).toBe(false);
expect(disableDownload('7.0.0')).toBe(false);
expect(disableDownload('8.0.0')).toBe(false);
});

it('always return false when the system is linux', () => {
Expand Down