Skip to content

Commit

Permalink
Add ARM64 support (#108)
Browse files Browse the repository at this point in the history
* Add ARM64 support

* Add Tests

* Test the tests

* Fix test

* Fix test

* Tests

* Remove log
  • Loading branch information
vladikoff committed Oct 19, 2022
1 parent ec8fdd5 commit ec29033
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 3,623 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Use `GECKODRIVER_SKIP_DOWNLOAD` to skip the download of the geckodriver file.
## Versions

* [npm module version] - [geckodriver version]
* 3.2.0 - geckodriver 0.32.0, arm64 support.
* 3.1.0 - geckodriver 0.31.0
* 3.0.x - geckodriver 0.30.0, refactored logic, dependency updates.
* 2.00.x - geckodriver 0.29.1, support changed to node v12+
Expand Down Expand Up @@ -113,6 +114,7 @@ Use `GECKODRIVER_SKIP_DOWNLOAD` to skip the download of the geckodriver file.

## Changelog

* 3.2.0 - geckodriver 0.32.0, arm64 support for Mac, Linux and Windows, added `GECKODRIVER_ARCH` for custom arch downloads.
* 3.1.0 - geckodriver 0.31.0
* 2.0.1 - fixed proxy download behaviour.
* 1.20.0 - geckodriver 27. Requires node 8 and higher. Support `HTTPS_PROXY` env and npm_config_geckodriver_version variables.
Expand Down
36 changes: 31 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var proxyAgent = require('https-proxy-agent');
var Promise = require('bluebird');

var platform = os.platform();
var arch = os.arch();
var arch = process.env.GECKODRIVER_ARCH || process.env.npm_config_geckodriver_arch || os.arch();

var skipDownload = process.env.GECKODRIVER_SKIP_DOWNLOAD || process.env.npm_config_geckodriver_skip_download;
if (skipDownload === 'true') {
Expand All @@ -21,20 +21,29 @@ if (skipDownload === 'true') {
var baseCDNURL = process.env.GECKODRIVER_CDNURL || process.env.npm_config_geckodriver_cdnurl || 'https://github.com/mozilla/geckodriver/releases/download';
var CACHED_ARCHIVE = process.env.GECKODRIVER_FILEPATH ? path.resolve(process.env.GECKODRIVER_FILEPATH) : undefined;

var version = process.env.GECKODRIVER_VERSION || process.env.npm_config_geckodriver_version || '0.30.0';
var version = process.env.GECKODRIVER_VERSION || process.env.npm_config_geckodriver_version || '0.32.0';

// Remove trailing slash if included
baseCDNURL = baseCDNURL.replace(/\/+$/, '');

var baseDownloadUrl = baseCDNURL + '/v' + version + '/geckodriver-v' + version;
var DOWNLOAD_MAC = baseDownloadUrl +'-macos.tar.gz';
var DOWNLOAD_MAC_ARM64 = baseDownloadUrl +'-macos-aarch64.tar.gz';

var DOWNLOAD_LINUX_ARM64 = baseDownloadUrl +'-linux-aarch64.tar.gz';
var DOWNLOAD_LINUX64 = baseDownloadUrl +'-linux64.tar.gz';
var DOWNLOAD_LINUX32 = baseDownloadUrl +'-linux32.tar.gz';

var DOWNLOAD_WIN_ARM64 = baseDownloadUrl +'-win-aarch64.zip';
var DOWNLOAD_WIN32 = baseDownloadUrl +'-win32.zip';
var DOWNLOAD_WIN64 = baseDownloadUrl +'-win64.zip';

// TODO: move this to package.json or something
var downloadUrl = DOWNLOAD_MAC;
if (arch === 'arm64') {
downloadUrl = DOWNLOAD_MAC_ARM64;
}

var outFile = 'geckodriver.tar.gz';
var executable = 'geckodriver';

Expand All @@ -45,12 +54,29 @@ if (proxy !== null) {
}

if (platform === 'linux') {
downloadUrl = arch === 'x64' ? DOWNLOAD_LINUX64 : DOWNLOAD_LINUX32;
switch (arch) {
case 'arm64':
downloadUrl = DOWNLOAD_LINUX_ARM64;
break;
case 'x64':
downloadUrl = DOWNLOAD_LINUX64;
break;
default:
downloadUrl = DOWNLOAD_LINUX32;
}
}

if (platform === 'win32') {
// No 32-bits of geckodriver for now
downloadUrl = arch === 'x64' ? DOWNLOAD_WIN64 : DOWNLOAD_WIN32;
switch (arch) {
case 'arm64':
downloadUrl = DOWNLOAD_WIN_ARM64;
break;
case 'x64':
downloadUrl = DOWNLOAD_WIN64;
break;
default:
downloadUrl = DOWNLOAD_WIN32;
}
outFile = 'geckodriver.zip';
executable = 'geckodriver.exe';
}
Expand Down
2 changes: 1 addition & 1 deletion lib/geckodriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ process.env.PATH += path.delimiter + path.join(__dirname, '..');
exports.path = process.platform === 'win32' ? path.join(__dirname, '..', 'geckodriver.exe') : path.join(__dirname, '..', 'geckodriver');

// specify the version of geckodriver
exports.version = process.env.GECKODRIVER_VERSION || '0.31.0';
exports.version = process.env.GECKODRIVER_VERSION || '0.32.0';

exports.start = function(args) {
exports.defaultInstance = require('child_process').execFile(exports.path, args);
Expand Down
Loading

0 comments on commit ec29033

Please sign in to comment.