on master help sign in
add verifyPlatform to npm installer

Hopefully this will be helpful for platforms that do not have official pre-built binaries.

commit759bf04a298a357018d13c85cbb315549893c26d authorEvan Czaplicki <evancz@users.noreply.github.com> dateFri 29 Jan 2021, 11:02 (6 years ago) parenta141816
1 file changed+35−3
installers/npm/download.js+35−3
installers/npm/download.js+35−3
@@ -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