From 0ab524a2aaedbc76f2ab0556826e7099ec50a32f Mon Sep 17 00:00:00 2001 From: yunyingk Date: Thu, 29 Oct 2026 15:12:01 +0800 Subject: [PATCH] =?UTF-8?q?feat(dev):=20dev:override=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E7=9B=AE=E5=BD=95=E6=9D=83=E9=99=90=E9=A2=84?= =?UTF-8?q?=E6=A3=80=E4=B8=8E=E5=8F=8B=E5=A5=BD=E7=9A=84=20sudo/=E8=BF=81?= =?UTF-8?q?=E7=A7=BB=E5=BC=95=E5=AF=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/dev-override.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/dev-override.ts b/scripts/dev-override.ts index 9a83daa..b8a7f41 100755 --- a/scripts/dev-override.ts +++ b/scripts/dev-override.ts @@ -1,5 +1,5 @@ #!/usr/bin/env bun -import { chmodSync, copyFileSync, existsSync, mkdirSync, realpathSync, renameSync, rmSync } from "node:fs"; +import { accessSync, chmodSync, constants, copyFileSync, existsSync, mkdirSync, realpathSync, renameSync, rmSync } from "node:fs"; import { spawnSync } from "node:child_process"; import { homedir } from "node:os"; import { dirname, join, resolve } from "node:path"; @@ -64,7 +64,19 @@ async function main() { const targetPath = resolveTargetBinaryPath(); const targetDir = dirname(targetPath); - mkdirSync(targetDir, { recursive: true }); + + try { + mkdirSync(targetDir, { recursive: true }); + accessSync(targetDir, constants.W_OK); + if (existsSync(targetPath)) { + accessSync(targetPath, constants.W_OK); + } + } catch { + console.error(`❌ [dev:override] Permission denied: Target path '${targetPath}' requires root privileges.`); + console.error(`👉 Next action: run with sudo: 'sudo bun run dev:override'`); + console.error(`💡 Tip: To develop without sudo, migrate to user directory first: 'seal-use update --user'`); + process.exit(1); + } console.error(`==> [dev:override] Installing to global path: ${targetPath}`);