修复arm64一直跳过下载chromium

原本的代码为只要设备为arm64就会一直跳过下载,无论是使用pnpm i puppeteer -w还是node node_modules/puppeteer/install.js,都无法安装浏览器,只能手动另外安装完整chrome
现在修改为arm64检测到安装过chromium才会跳过下载,方便安装puppeteer带的chromium

Signed-off-by: 所有二刺螈都得死 <321107534@qq.com>
This commit is contained in:
所有二刺螈都得死 2023-08-07 02:53:43 +00:00 committed by Gitee
parent 9b9ec42ffa
commit 30e1b1be9a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 10 additions and 12 deletions

View File

@ -3,22 +3,20 @@ const { existsSync } = require("fs");
const arch = os.arch(); const arch = os.arch();
let skipDownload = false; let skipDownload = false;
let executablePath; let executablePath;
// win32 存在 Edge 优先选择 // win32 存在 Edge 优先选择
if (process.platform == "win32") { if (process.platform == "win32") {
if ( if (existsSync("C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe")) {
existsSync("C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe")
) {
skipDownload = true; skipDownload = true;
executablePath = executablePath = "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe";
"C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe";
} }
} else if (process.platform == "linux") { } else if (process.platform == "linux") {
//如果arm64架构跳过下载 // 如果 arm64 架构且存在 Chromium跳过下载
if (arch == "arm64" || arch == "aarch64") { if ((arch == "arm64" || arch == "aarch64") && existsSync("/usr/bin/chromium")) {
skipDownload = true; skipDownload = true;
} executablePath = "/usr/bin/chromium";
//不管什么架构,如果存在配置则跳过下载,且配置路径 } else if (existsSync("/usr/bin/chromium")) {
if (existsSync("/usr/bin/chromium")) { // 不论什么架构,如果存在 Chromium跳过下载且配置路径
skipDownload = true; skipDownload = true;
executablePath = "/usr/bin/chromium"; executablePath = "/usr/bin/chromium";
} }