From f15441a66ca68709ad5629dcd66a262fd1c71214 Mon Sep 17 00:00:00 2001 From: waruhachi <156133757+waruhachi@users.noreply.github.com> Date: Wed, 2 Oct 2024 11:22:47 -0500 Subject: [PATCH] [feat] Account for non-Intel Macs to download the correct Java JRE --- src/providers/JavaDownload.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/providers/JavaDownload.ts b/src/providers/JavaDownload.ts index 2d2f19a..0ea051f 100644 --- a/src/providers/JavaDownload.ts +++ b/src/providers/JavaDownload.ts @@ -33,13 +33,25 @@ export async function getJre(ref: Ref): Promise { const platform: NodeJS.Platform = await ipcRenderer.invoke('getPlatform'); // const platform: NodeJS.Platform = 'linux'; + const getMacArch = () => { + const arch = os.arch(); + + if (arch === 'x64') { + return 'x64'; + } else if (arch === 'arm64') { + return 'aarch64'; + } + + return arch; + }; + const flags = { // https://api.adoptium.net/q/swagger-ui/#/Binary/getBinary // /v3/binary/latest/{feature_version}/{release_type}/{os}/{arch}/{image_type}/{jvm_impl}/{heap_size}/{vendor} feature_version: '17', // Drehmal is 1.17+, so use JRE 17 release_type: 'ga', os: osMap[platform], - arch: os.arch(), + arch: platform === 'darwin' ? getMacArch() : os.arch(), image_type: 'jre', jvm_impl: 'hotspot', heap_size: 'normal',