From 0ad4fc95442c21d2a76ee7c1ed32541fd651d763 Mon Sep 17 00:00:00 2001 From: Yanhao-MBP Date: Tue, 25 Nov 2025 15:26:14 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"fix:=20=E4=BF=AE=E5=A4=8D=20PowerShel?= =?UTF-8?q?l=20=E8=84=9A=E6=9C=AC=E4=B8=AD=E7=9A=84=20ARM64=20=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E9=80=BB=E8=BE=91=E5=B9=B6=E6=B7=BB=E5=8A=A0=E8=B0=83?= =?UTF-8?q?=E8=AF=95=E6=89=93=E5=8D=B0"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 4168d205ee4cc7b860aa99cbeaf7121c62ab8a08. --- src/worker.js | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/src/worker.js b/src/worker.js index 091d28f..88ed5be 100644 --- a/src/worker.js +++ b/src/worker.js @@ -6,48 +6,17 @@ export default { return new Response(`curl -fsSL ${url.origin}/install.sh | sh - iwr ${url.origin}/install.ps1 -useb | iex -# 常用命令 pnpm env use --global lts pnpm config get registry pnpm config set registry https://registry.npmmirror.com `); } - // 2. 代理请求 let response = await fetch(`http://get.pnpm.io${url.pathname}`); let text = await response.text(); - - // 3. GitHub 加速替换 text = text.replace(/https:\/\/github.com/g, 'https://ghfast.top/https://github.com'); text = text.replace('Downloading pnpm from GitHub', 'Downloading pnpm from GitHub (via Cloudflare)'); text = text.replace('Downloading pnpm', 'Downloading pnpm (via Cloudflare)'); - - // 4. 【核心修改】针对 PowerShell 脚本 (install.ps1) - if (url.pathname.endsWith('.ps1')) { - // --- 修改 A: 修复 ARM64 判断逻辑 --- - const originalLogicRegex = - /if \(\$platform -eq 'win'\)\s*\{\s*if \(\[System\.Environment\]::Is64BitOperatingSystem -eq \$true\)\s*\{\s*\$architecture = 'x64'/; - - // 使用 elseif 结构,优先判断环境变量是否为 ARM64 - const patchedLogic = `if ($platform -eq 'win') { - if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { - $architecture = 'arm64' - } elseif ([System.Environment]::Is64BitOperatingSystem -eq $true) { - $architecture = 'x64'`; - - text = text.replace(originalLogicRegex, patchedLogic); - - // --- 修改 B: 插入 Debug 打印 --- - // 这里的注入点选择在脚本判断完所有架构之后,检查 platform 是否为空之前 - // 这样能确保打印出最终判定结果 - const debugPrint = ` -Write-Host "DEBUG: Platform = $platform" -ForegroundColor Cyan -Write-Host "DEBUG: Architecture = $architecture" -ForegroundColor Cyan -if ($null -eq $platform) {`; - - text = text.replace('if ($null -eq $platform) {', debugPrint); - } - return new Response(text); }, };