Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Determine which specific ARM version a given host arch is running, so the appropriate Electron binary is selected. This is particularly important as of Electron 3, since `-arm` builds are no longer being created.
- Loading branch information
Showing
4 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict' | ||
|
||
const execSync = require('child_process').execSync | ||
|
||
module.exports = { | ||
host: function host (quiet) { | ||
const arch = process.arch | ||
if (arch === 'arm') { | ||
switch (process.config.variables.arm_version) { | ||
case '6': | ||
return module.exports.uname() | ||
case '7': | ||
return 'armv7l' | ||
default: | ||
if (!quiet) { | ||
console.warn(`WARNING: Could not determine specific ARM arch. Detected ARM version: ${JSON.stringify(process.config.variables.arm_version)}`) | ||
} | ||
} | ||
} | ||
|
||
return arch | ||
}, | ||
|
||
/** | ||
* Returns the arch name from the `uname` utility. | ||
*/ | ||
uname: function uname () { | ||
return execSync('uname -m').toString().trim() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict' | ||
|
||
const arch = require('../lib/arch') | ||
const sinon = require('sinon') | ||
const test = require('tape') | ||
|
||
test('hostArch detects incorrectly configured armv7l Node', t => { | ||
sinon.stub(arch, 'uname').returns('armv6l') | ||
sinon.stub(process, 'arch').value('arm') | ||
sinon.stub(process, 'config').value({variables: {arm_version: '6'}}) | ||
|
||
t.is(arch.host(), 'armv6l') | ||
|
||
sinon.restore() | ||
t.end() | ||
}) | ||
|
||
test('hostArch detects correctly configured armv7l Node', t => { | ||
sinon.stub(process, 'arch').value('arm') | ||
sinon.stub(process, 'config').value({variables: {arm_version: '7'}}) | ||
|
||
t.is(arch.host(), 'armv7l') | ||
|
||
sinon.restore() | ||
t.end() | ||
}) | ||
|
||
test('hostArch cannot determine ARM version', t => { | ||
sinon.stub(process, 'arch').value('arm') | ||
sinon.stub(process, 'config').value({variables: {arm_version: '99'}}) | ||
|
||
t.is(arch.host(), 'arm') | ||
|
||
sinon.restore() | ||
t.end() | ||
}) |