fix(ui): run ui script through junction paths (#85525) · openclaw/openclaw@ad19dd8
giodl73-repo
·
2026-05-23
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -207,10 +207,29 @@ export function main(argv = process.argv.slice(2)) {
|
207 | 207 | run(runner.cmd, ["run", script, ...rest]); |
208 | 208 | } |
209 | 209 | |
210 | | -const isDirectExecution = (() => { |
211 | | -const entry = process.argv[1]; |
212 | | -return Boolean(entry && path.resolve(entry) === fileURLToPath(import.meta.url)); |
213 | | -})(); |
| 210 | +export function resolveDirectExecutionPath(entry, realpath = fs.realpathSync.native) { |
| 211 | +const resolved = path.resolve(entry); |
| 212 | +try { |
| 213 | +return realpath(resolved); |
| 214 | +} catch { |
| 215 | +return resolved; |
| 216 | +} |
| 217 | +} |
| 218 | + |
| 219 | +export function isDirectScriptExecution( |
| 220 | +entry = process.argv[1], |
| 221 | +scriptPath = fileURLToPath(import.meta.url), |
| 222 | +realpath = fs.realpathSync.native, |
| 223 | +) { |
| 224 | +if (!entry) { |
| 225 | +return false; |
| 226 | +} |
| 227 | +return ( |
| 228 | +resolveDirectExecutionPath(entry, realpath) === resolveDirectExecutionPath(scriptPath, realpath) |
| 229 | +); |
| 230 | +} |
| 231 | + |
| 232 | +const isDirectExecution = isDirectScriptExecution(); |
214 | 233 | |
215 | 234 | if (isDirectExecution) { |
216 | 235 | main(); |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import path from "node:path"; |
1 | 2 | import { describe, expect, it } from "vitest"; |
2 | | -import { resolveSpawnCall, shouldUseCmdExeForCommand } from "../../scripts/ui.js"; |
| 3 | +import { |
| 4 | +isDirectScriptExecution, |
| 5 | +resolveSpawnCall, |
| 6 | +shouldUseCmdExeForCommand, |
| 7 | +} from "../../scripts/ui.js"; |
3 | 8 | |
4 | 9 | describe("scripts/ui windows spawn behavior", () => { |
5 | 10 | it("wraps Windows command launchers with cmd.exe without enabling shell mode", () => { |
@@ -88,4 +93,12 @@ describe("scripts/ui windows spawn behavior", () => {
|
88 | 93 | }, |
89 | 94 | }); |
90 | 95 | }); |
| 96 | + |
| 97 | +it("detects direct execution through a junctioned script path", () => { |
| 98 | +const realScriptPath = path.resolve("repo/openclaw/scripts/ui.js"); |
| 99 | +const junctionScriptPath = path.resolve("linked/openclaw/scripts/ui.js"); |
| 100 | +const realpath = (entry: string) => (entry === junctionScriptPath ? realScriptPath : entry); |
| 101 | + |
| 102 | +expect(isDirectScriptExecution(junctionScriptPath, realScriptPath, realpath)).toBe(true); |
| 103 | +}); |
91 | 104 | }); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。