-
Notifications
You must be signed in to change notification settings - Fork 9
/
.puppeteerrc.cjs
67 lines (67 loc) · 1.56 KB
/
.puppeteerrc.cjs
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const { arch } = require('os')
const { existsSync, realpathSync } = require('fs')
const { execSync } = require('child_process')
const isArch = arch()
const platform = process.platform
const win32Edge = 'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe'
// Downloa
let skipDownload = false
// Path
let executablePath
if (process.platform == 'win32' && existsSync(win32Edge)) {
// win32 Edge
skipDownload = true
executablePath = win32Edge
} else if (platform == 'linux' || platform == 'android') {
// linux | android
const chromium = [
'whereis chrome-browser',
'whereis chrome',
'whereis chromium-browser',
'whereis chromium',
'whereis firefox'
]
// get path
for (const item of chromium) {
try {
const chromiumPath = execSync(item).toString().split(' ')[1]?.trim()
if (chromiumPath) {
skipDownload = true
executablePath = realpathSync(chromiumPath)
break
}
} catch (error) {
continue
}
}
// not path
if (!skipDownload) {
/**
* search
*/
const arr = [
'/usr/bin/chromium',
'/snap/bin/chromium',
'/usr/bin/chromium-browser',
'/data/data/com.termux/files/usr/lib/chromium-browser'
]
for (const item of arr) {
if (existsSync(item)) {
skipDownload = true
executablePath = item
break
}
}
}
// arm64/arrch64
if (isArch == 'arm64' || isArch == 'aarch64') {
skipDownload = true
}
}
/**
* @type {import("puppeteer").Configuration}
*/
module.exports = {
skipDownload,
executablePath
}