Ensure prebuilt binaries for ARM default to v7 when using Electron

This commit is contained in:
diegodev3 2020-07-13 10:18:21 -03:00 committed by Lovell Fuller
parent 77c861b74b
commit 45653ca2e7
3 changed files with 14 additions and 1 deletions

View File

@ -23,6 +23,10 @@ Requires libvips v8.10.0
[#2259](https://github.com/lovell/sharp/pull/2259) [#2259](https://github.com/lovell/sharp/pull/2259)
[@vouillon](https://github.com/vouillon) [@vouillon](https://github.com/vouillon)
* Ensure prebuilt binaries for ARM default to v7 when using Electron.
[#2292](https://github.com/lovell/sharp/pull/2292)
[@diegodev3](https://github.com/diegodev3)
## v0.25 - *yield* ## v0.25 - *yield*
Requires libvips v8.9.1 Requires libvips v8.9.1

View File

@ -13,7 +13,8 @@ module.exports = function () {
const platformId = [`${platform}${libc}`]; const platformId = [`${platform}${libc}`];
if (arch === 'arm') { if (arch === 'arm') {
platformId.push(`armv${env.npm_config_arm_version || process.config.variables.arm_version || '6'}`); const fallback = process.versions.electron ? '7' : '6';
platformId.push(`armv${env.npm_config_arm_version || process.config.variables.arm_version || fallback}`);
} else if (arch === 'arm64') { } else if (arch === 'arm64') {
platformId.push(`arm64v${env.npm_config_arm_version || '8'}`); platformId.push(`arm64v${env.npm_config_arm_version || '8'}`);
} else { } else {

View File

@ -55,4 +55,12 @@ describe('Platform-detection', function () {
assert.strictEqual('arm64v8', platform().split('-')[1]); assert.strictEqual('arm64v8', platform().split('-')[1]);
delete process.env.npm_config_arch; delete process.env.npm_config_arch;
}); });
it('Can ensure version ARMv7 if electron version is present', function () {
process.env.npm_config_arch = 'arm';
process.versions.electron = 'test';
assert.strictEqual('armv7', platform().split('-')[1]);
delete process.env.npm_config_arch;
delete process.versions.electron;
});
}); });