variable isARM64, remove includes

This commit is contained in:
r1tsuu 2023-03-07 10:59:46 +02:00
parent 96c1a5d7a8
commit 4eb799b9c5

View File

@ -143,6 +143,9 @@ class DLTracker {
class Util { class Util {
isARM64 = process.arch === "arm64";
/** /**
* Returns true if the actual version is greater than * Returns true if the actual version is greater than
* or equal to the desired version. * or equal to the desired version.
@ -150,6 +153,7 @@ class Util {
* @param {string} desired The desired version. * @param {string} desired The desired version.
* @param {string} actual The actual version. * @param {string} actual The actual version.
*/ */
static mcVersionAtLeast(desired, actual){ static mcVersionAtLeast(desired, actual){
const des = desired.split('.') const des = desired.split('.')
const act = actual.split('.') const act = actual.split('.')
@ -302,7 +306,7 @@ class JavaGuard extends EventEmitter {
break break
} }
const arch = process.arch.includes('arm') ? 'aarch64' : 'x64' const arch = isARM64 ? 'aarch64' : 'x64'
const url = `https://corretto.aws/downloads/latest/amazon-corretto-${major}-${arch}-${sanitizedOS}-jdk.${ext}` const url = `https://corretto.aws/downloads/latest/amazon-corretto-${major}-${arch}-${sanitizedOS}-jdk.${ext}`
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -904,7 +908,7 @@ class JavaGuard extends EventEmitter {
// TODO Revise this a bit, seems to work for now. Discovery logic should // TODO Revise this a bit, seems to work for now. Discovery logic should
// probably just filter out the invalid architectures before it even // probably just filter out the invalid architectures before it even
// gets to this point. // gets to this point.
if (process.arch.includes('arm')) { if (isARM64) {
return pathArr.find(({ isARM }) => isARM)?.execPath ?? null return pathArr.find(({ isARM }) => isARM)?.execPath ?? null
} else { } else {
return pathArr.find(({ isARM }) => !isARM)?.execPath ?? null return pathArr.find(({ isARM }) => !isARM)?.execPath ?? null