Skip to content

Commit

Permalink
Add support for Apple Silicon and other ARM builds (#115)
Browse files Browse the repository at this point in the history
* Add arm_64 platforms

* Update lib/aliases.js

Co-authored-by: Leo Lamprecht <mindrun@icloud.com>

* Apply suggestions from code review

Co-authored-by: Leo Lamprecht <mindrun@icloud.com>

Co-authored-by: Leo Lamprecht <mindrun@icloud.com>
  • Loading branch information
LabhanshAgrawal and leo authored Jul 23, 2021
1 parent a073ccd commit 10b9813
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/aliases.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ const aliases = {
dmg: ['dmg']
}

for (const existingPlatform of Object.keys(aliases)) {
const newPlatform = existingPlatform + '_arm64';
aliases[newPlatform] = aliases[existingPlatform].map(alias => `${alias}_arm64`);
}

module.exports = platform => {
if (typeof aliases[platform] !== 'undefined') {
return platform
Expand Down
5 changes: 3 additions & 2 deletions lib/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ const { extname } = require('path')

module.exports = fileName => {
const extension = extname(fileName).slice(1)
const arch = (fileName.includes('arm64') || fileName.includes('aarch64')) ? '_arm64' : ''

if (
(fileName.includes('mac') || fileName.includes('darwin')) &&
extension === 'zip'
) {
return 'darwin'
return 'darwin' + arch
}

const directCache = ['exe', 'dmg', 'rpm', 'deb', 'AppImage']
return directCache.find(ext => ext === extension) || false
return directCache.includes(extension) ? (extension + arch) : false
}
4 changes: 4 additions & 0 deletions lib/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ module.exports = ({ cache, config }) => {
platform = 'dmg'
}

if (platform === 'mac_arm64' && !isUpdate) {
platform = 'dmg_arm64'
}

// Get the latest version from the cache
const latest = await loadCache()

Expand Down

1 comment on commit 10b9813

@vercel
Copy link

@vercel vercel bot commented on 10b9813 Jul 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

Please sign in to comment.