Skip to content

Commit a25c0fb

Browse files
maleptMarshallOfSound
authored andcommitted
feat: emit warning if downloading a deprecated linux/ia32 binary (#100)
1 parent 06c86ea commit a25c0fb

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

src/index.ts

+20-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ import { getArtifactFileName, getArtifactRemoteURL, FileNameUse } from './artifa
55
import { ElectronArtifactDetails, ElectronDownloadRequestOptions } from './types';
66
import { Cache } from './Cache';
77
import { getDownloaderForSystem } from './downloader-resolver';
8-
import { withTempDirectory, normalizeVersion, getHostArch, ensureIsTruthyString } from './utils';
8+
import {
9+
withTempDirectory,
10+
normalizeVersion,
11+
getHostArch,
12+
ensureIsTruthyString,
13+
isOfficialLinuxIA32Download,
14+
} from './utils';
915

1016
export { getHostArch } from './utils';
1117

@@ -60,6 +66,19 @@ export async function downloadArtifact(_artifactDetails: ElectronArtifactDetails
6066
}
6167
}
6268

69+
if (
70+
!artifactDetails.isGeneric &&
71+
isOfficialLinuxIA32Download(
72+
artifactDetails.platform,
73+
artifactDetails.arch,
74+
artifactDetails.version,
75+
artifactDetails.mirrorOptions,
76+
)
77+
) {
78+
console.warn('Official Linux/ia32 support is deprecated.');
79+
console.warn('For more info: https://electronjs.org/blog/linux-32bit-support');
80+
}
81+
6382
return await withTempDirectory(async tempFolder => {
6483
const tempDownloadPath = path.resolve(
6584
tempFolder,

src/utils.ts

+14
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,17 @@ export function ensureIsTruthyString<T, K extends keyof T>(obj: T, key: K) {
7171
throw new Error(`Expected property "${key}" to be provided as a string but it was not`);
7272
}
7373
}
74+
75+
export function isOfficialLinuxIA32Download(
76+
platform: string,
77+
arch: string,
78+
version: string,
79+
mirrorOptions?: object,
80+
) {
81+
return (
82+
platform === 'linux' &&
83+
arch === 'ia32' &&
84+
Number(version.slice(1).split('.')[0]) >= 4 &&
85+
typeof mirrorOptions === 'undefined'
86+
);
87+
}

test/utils.spec.ts

+22
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
withTempDirectory,
77
getHostArch,
88
ensureIsTruthyString,
9+
isOfficialLinuxIA32Download,
910
} from '../src/utils';
1011

1112
describe('utils', () => {
@@ -127,4 +128,25 @@ describe('utils', () => {
127128
expect(() => ensureIsTruthyString({ a: 1234 }, 'a')).toThrow();
128129
});
129130
});
131+
132+
describe('isOfficialLinuxIA32Download()', () => {
133+
it('should be true if an official linux/ia32 download with correct version specified', () => {
134+
expect(isOfficialLinuxIA32Download('linux', 'ia32', 'v4.0.0')).toEqual(true);
135+
});
136+
137+
it('should be false if mirrorOptions specified', () => {
138+
expect(
139+
isOfficialLinuxIA32Download('linux', 'ia32', 'v4.0.0', { mirror: 'mymirror' }),
140+
).toEqual(false);
141+
});
142+
143+
it('should be false if too early version specified', () => {
144+
expect(isOfficialLinuxIA32Download('linux', 'ia32', 'v3.0.0')).toEqual(false);
145+
});
146+
147+
it('should be false if wrong platform/arch specified', () => {
148+
expect(isOfficialLinuxIA32Download('win32', 'ia32', 'v4.0.0')).toEqual(false);
149+
expect(isOfficialLinuxIA32Download('linux', 'x64', 'v4.0.0')).toEqual(false);
150+
});
151+
});
130152
});

0 commit comments

Comments
 (0)