From 9bd1923b26c1530ddbc006c40ba5805c04f732af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naz=C4=B1m=20Can=20Alt=C4=B1nova?= Date: Sun, 26 Nov 2023 21:56:29 +0100 Subject: [PATCH] Install the arm64 binary if we are on an arm64 macOS (#14) --- install.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/install.js b/install.js index eb5372b..5060cf3 100644 --- a/install.js +++ b/install.js @@ -8,6 +8,7 @@ const pkg = require('./package'); const { DownloaderHelper } = require('node-downloader-helper'); const { promisify } = require('util'); const tar = require('tar'); +const semver = require('semver'); const unlink = promisify(fs.unlink); const mkdir = promisify(fs.mkdir); const chmod = promisify(fs.chmod); @@ -42,7 +43,13 @@ function getDriverUrl() { switch (os.platform()) { case 'darwin': - return `${urlBase}geckodriver-${GECKODRIVER_VERSION}-macos.tar.gz`; + // Starting from Geckodriver v0.29.1, there is a separate build for arm64 + // architecture. Let's install it if we are on arm64 as well. + const arch = + os.arch() === 'arm64' && semver.gte(GECKODRIVER_VERSION, '0.29.1') + ? '-aarch64' + : ''; + return `${urlBase}geckodriver-${GECKODRIVER_VERSION}-macos${arch}.tar.gz`; case 'linux': { if (os.arch() === 'arm') { // Don't want to spend hours to build a new one, so for now serve 0.29.0