-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
32 lines (30 loc) · 943 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'use strict';
const os = require('os');
const path = require('path');
const pkg = require('./package');
const { execSync } = require('child_process');
module.exports = {
version: pkg.geckodriver_version,
binPath: function() {
let driverPath = path.resolve(__dirname, 'vendor', 'geckodriver');
if (os.platform() === 'win32') {
return driverPath + '.exe';
} else if (
(os.platform() === 'linux' && os.arch() === 'arm') ||
(os.platform() === 'linux' && os.arch() === 'arm64')
) {
// Special handling for making it easy on Raspberry Pis
try {
const potentialGeckodriverPath = execSync('which geckodriver');
if (potentialGeckodriverPath !== undefined) {
return potentialGeckodriverPath.toString().trim();
}
} catch (e) {
// Catch running inside of Docker on ARM
return driverPath;
}
} else {
return driverPath;
}
}
};