-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
31 lines (29 loc) · 881 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
'use strict';
const os = require('os');
const path = require('path');
const { execSync } = require('child_process');
const pkg = require('./package');
module.exports = {
version: pkg.version,
binPath: function() {
let driverPath = path.resolve(__dirname, 'vendor', 'chromedriver');
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 potentialChromdriverPath = execSync('which chromedriver');
if (potentialChromdriverPath !== undefined) {
return potentialChromdriverPath.toString().trim();
}
} catch (e) {
// Just swallow
}
} else {
return driverPath;
}
}
};