forked from dtolstyi/node-chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.js
38 lines (28 loc) · 1.04 KB
/
utils.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
33
34
35
36
37
38
'use strict';
const path = require('path');
const config = require('./config');
module.exports = {
getOsChromiumFolderName() {
const platform = process.platform;
let archivePlatformPrefix = platform;
if (platform === 'darwin') {
archivePlatformPrefix = 'mac';
}
return `chrome-${archivePlatformPrefix}`;
},
getOsChromiumBinPath() {
let binPath = path.join(config.BIN_OUT_PATH, this.getOsChromiumFolderName());
const platform = process.platform;
if (platform === 'linux') {
binPath = path.join(binPath, 'chrome');
} else if (platform === 'win32') {
binPath = path.join(binPath, 'chrome.exe');
} else if (platform === 'darwin') {
binPath = path.join(binPath, 'Chromium.app/Contents/MacOS/Chromium');
} else {
console.error('Unsupported platform or architecture found:', process.platform, process.arch);
throw new Error('Unsupported platform');
}
return binPath;
}
};