2023-09-06 03:00:17 +08:00
|
|
|
const os = require("os")
|
2023-09-06 13:00:35 +08:00
|
|
|
const { existsSync } = require("fs")
|
2023-09-06 03:00:17 +08:00
|
|
|
const { execSync } = require("child_process")
|
|
|
|
const arch = os.arch()
|
|
|
|
|
|
|
|
let skipDownload = false
|
|
|
|
let executablePath
|
|
|
|
|
|
|
|
if (process.platform == "linux" || process.platform == "android")
|
|
|
|
for (const item of [
|
|
|
|
"chromium",
|
|
|
|
"chromium-browser",
|
|
|
|
"chrome",
|
|
|
|
]) try {
|
|
|
|
const chromiumPath = execSync(`command -v ${item}`).toString().trim()
|
|
|
|
if (chromiumPath && existsSync(chromiumPath)) {
|
2023-09-06 13:00:35 +08:00
|
|
|
executablePath = chromiumPath
|
2023-09-06 03:00:17 +08:00
|
|
|
break
|
2023-09-03 18:24:26 +08:00
|
|
|
}
|
2023-09-06 03:00:17 +08:00
|
|
|
} catch (err) {}
|
|
|
|
|
|
|
|
if (!executablePath) for (const item of [
|
|
|
|
"/usr/bin/chromium",
|
|
|
|
"/usr/bin/chromium-browser",
|
2023-09-06 13:00:35 +08:00
|
|
|
"/usr/bin/chrome",
|
|
|
|
"C:/Program Files/Google/Chrome/Application/chrome.exe",
|
|
|
|
"C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe",
|
2023-09-06 03:00:17 +08:00
|
|
|
]) if (existsSync(item)) {
|
|
|
|
executablePath = item
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
if (executablePath || arch == "arm64" || arch == "aarch64") {
|
|
|
|
(typeof logger == "object" ? logger : console).info(`[Chromium] ${executablePath}`)
|
|
|
|
skipDownload = true
|
2023-08-14 13:09:35 +08:00
|
|
|
}
|
2023-09-06 03:00:17 +08:00
|
|
|
|
|
|
|
module.exports = { skipDownload, executablePath }
|