From d722728ee019d65396fb0713b290b1168c411697 Mon Sep 17 00:00:00 2001 From: alger Date: Sun, 10 May 2026 12:32:10 +0800 Subject: [PATCH] =?UTF-8?q?chore(scripts):=20=E7=A7=BB=E5=8A=A8=20fix-sand?= =?UTF-8?q?box.js=20=E5=88=B0=20scripts=20=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将根目录的运维脚本统一收纳到 scripts/,并把脚本内的相对路径 改为基于 __dirname,避免在仓库子目录执行时找不到 node_modules。 --- package.json | 2 +- fix-sandbox.js => scripts/fix-sandbox.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename fix-sandbox.js => scripts/fix-sandbox.js (82%) diff --git a/package.json b/package.json index 13c00f3..fe3ae64 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "dev:web": "vite dev", "build": "electron-vite build", "postinstall": "electron-builder install-app-deps", - "fix-sandbox": "node fix-sandbox.js", + "fix-sandbox": "node scripts/fix-sandbox.js", "build:unpack": "npm run build && electron-builder --dir", "build:win": "npm run build && electron-builder --win --publish never", "build:mac": "npm run build && electron-builder --mac --x64 --publish never && cp dist/latest-mac.yml dist/latest-mac-x64.yml && electron-builder --mac --arm64 --publish never && cp dist/latest-mac.yml dist/latest-mac-arm64.yml && node scripts/merge_latest_mac_yml.mjs dist/latest-mac-x64.yml dist/latest-mac-arm64.yml dist/latest-mac.yml", diff --git a/fix-sandbox.js b/scripts/fix-sandbox.js similarity index 82% rename from fix-sandbox.js rename to scripts/fix-sandbox.js index 2e99251..c47998b 100644 --- a/fix-sandbox.js +++ b/scripts/fix-sandbox.js @@ -3,14 +3,14 @@ * chrome-sandbox 需要 root 拥有且权限为 4755 * * 注意:此脚本需要 sudo 权限,仅在 CI 环境或手动执行时使用 - * 用法:sudo node fix-sandbox.js + * 用法:sudo npm run fix-sandbox */ const { execSync } = require('child_process'); const fs = require('fs'); const path = require('path'); if (process.platform === 'linux') { - const sandboxPath = path.resolve('./node_modules/electron/dist/chrome-sandbox'); + const sandboxPath = path.resolve(__dirname, '../node_modules/electron/dist/chrome-sandbox'); if (fs.existsSync(sandboxPath)) { execSync(`sudo chown root:root ${sandboxPath}`); execSync(`sudo chmod 4755 ${sandboxPath}`);