-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.puppeteerrc.js
43 lines (36 loc) · 916 Bytes
/
.puppeteerrc.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
39
40
41
42
43
const fs = require('fs')
const { resolve } = require('path')
const path = require('path')
const serverInfo = (() => {
try {
const tmpServerInfo = fs.readFileSync(
path.resolve(__dirname, './server/server-info.json')
)
return JSON.parse(tmpServerInfo)
} catch (err) {
console.log(err)
return {}
}
})()
const canUseLinuxChromium = serverInfo.platform?.toLowerCase?.() === 'linux'
const browserCachePath = (() => {
let path = ''
if (
process.env.PUPPETEER_CACHE_DIR &&
fs.existsSync(process.env.PUPPETEER_CACHE_DIR)
)
path = process.env.PUPPETEER_CACHE_DIR
else {
path = resolve(__dirname, './node_modules/.puppeteer-cache')
if (!fs.existsSync(path)) fs.mkdirSync(path)
}
return path
})()
/**
* @type {import("puppeteer").Configuration}
*/
module.exports = {
// Changes the cache location for Puppeteer.
cacheDirectory: browserCachePath,
skipDownload: canUseLinuxChromium,
}