Skip to content

Commit 759bf04

Browse files
committed
add verifyPlatform to npm installer
Hopefully this will be helpful for platforms that do not have official pre-built binaries.
1 parent a141816 commit 759bf04

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

installers/npm/download.js

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,17 @@ module.exports = function(callback)
1616
{
1717
// figure out URL of binary
1818
var version = package.version.replace(/^(\d+\.\d+\.\d+).*$/, '$1'); // turn '1.2.3-alpha' into '1.2.3'
19-
var os = { 'darwin': 'mac', 'win32': 'windows', 'linux': 'linux' }[process.platform];
20-
var arch = { 'x64': '64-bit', 'arm64': '64-bit', 'ia32': '32-bit' }[process.arch];
21-
var url = 'https://github.com/elm/compiler/releases/download/' + version + '/binary-for-' + os + '-' + arch + '.gz';
19+
20+
var platform = {
21+
darwin_x64: 'mac-64-bit',
22+
darwin_arm64: 'mac-64-bit',
23+
win32_x64: 'windows-64-bit',
24+
linux_x64: 'linux-64-bit'
25+
}[process.platform + '_' + process.arch];
26+
27+
verifyPlatform(version, platform);
28+
29+
var url = 'https://github.com/elm/compiler/releases/download/' + version + '/binary-for-' + platform + '.gz';
2230

2331
reportDownload(version, url);
2432

@@ -50,6 +58,30 @@ module.exports = function(callback)
5058

5159

5260

61+
// VERIFY PLATFORM
62+
63+
64+
function verifyPlatform(version, platform)
65+
{
66+
if (platform) return;
67+
68+
var situation = process.platform + '_' + process.arch;
69+
console.error(
70+
'-- ERROR -----------------------------------------------------------------------\n\n'
71+
+ 'I am detecting that your computer (' + situation + ') may not be compatible with any\n'
72+
+ 'of the official pre-built binaries.\n\n'
73+
+ 'I recommend against using the npm installer for your situation. Check out the\n'
74+
+ 'alternative installers at https://github.com/elm/compiler/releases/tag/' + version + '\n'
75+
+ 'to see if there is something that will work better for you.\n\n'
76+
+ 'From there I recommend asking for guidance on Slack or Discourse to find someone\n'
77+
+ 'who can help with your specific situation.\n\n'
78+
+ '--------------------------------------------------------------------------------\n'
79+
);
80+
process.exit(1);
81+
}
82+
83+
84+
5385
// EXIT FAILURE
5486

5587

0 commit comments

Comments
 (0)