chore(scripts): 移动 fix-sandbox.js 到 scripts 目录

将根目录的运维脚本统一收纳到 scripts/,并把脚本内的相对路径
改为基于 __dirname,避免在仓库子目录执行时找不到 node_modules。
This commit is contained in:
alger
2026-05-10 12:32:10 +08:00
parent 5ba9e6591a
commit d722728ee0
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -18,7 +18,7 @@
"dev:web": "vite dev", "dev:web": "vite dev",
"build": "electron-vite build", "build": "electron-vite build",
"postinstall": "electron-builder install-app-deps", "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:unpack": "npm run build && electron-builder --dir",
"build:win": "npm run build && electron-builder --win --publish never", "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", "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",
+2 -2
View File
@@ -3,14 +3,14 @@
* chrome-sandbox 需要 root 拥有且权限为 4755 * chrome-sandbox 需要 root 拥有且权限为 4755
* *
* 注意此脚本需要 sudo 权限仅在 CI 环境或手动执行时使用 * 注意此脚本需要 sudo 权限仅在 CI 环境或手动执行时使用
* 用法sudo node fix-sandbox.js * 用法sudo npm run fix-sandbox
*/ */
const { execSync } = require('child_process'); const { execSync } = require('child_process');
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
if (process.platform === 'linux') { 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)) { if (fs.existsSync(sandboxPath)) {
execSync(`sudo chown root:root ${sandboxPath}`); execSync(`sudo chown root:root ${sandboxPath}`);
execSync(`sudo chmod 4755 ${sandboxPath}`); execSync(`sudo chmod 4755 ${sandboxPath}`);