Skip to content

Commit 993ca32

Browse files
committed
feat: refactor UV command handling to use BuildUvPathFromUvx method
1 parent b3320d9 commit 993ca32

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

MCPForUnity/Editor/Services/ServerManagementService.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public bool ClearUvxCache()
2222
try
2323
{
2424
string uvxPath = MCPServiceLocator.Paths.GetUvxPath();
25-
string uvCommand = uvxPath.Remove(uvxPath.Length - 1, 1);
25+
string uvCommand = BuildUvPathFromUvx(uvxPath);
2626

2727
// Get the package name
2828
string packageName = "mcp-for-unity";
@@ -73,7 +73,7 @@ private bool ExecuteUvCommand(string uvCommand, string args, out string stdout,
7373
stderr = null;
7474

7575
string uvxPath = MCPServiceLocator.Paths.GetUvxPath();
76-
string uvPath = uvxPath.Remove(uvxPath.Length - 1, 1);
76+
string uvPath = BuildUvPathFromUvx(uvxPath);
7777

7878
if (!string.Equals(uvCommand, uvPath, StringComparison.OrdinalIgnoreCase))
7979
{
@@ -99,6 +99,22 @@ private bool ExecuteUvCommand(string uvCommand, string args, out string stdout,
9999
return ExecPath.TryRun(uvPath, args, Application.dataPath, out stdout, out stderr, 30000, extraPathPrepend);
100100
}
101101

102+
private static string BuildUvPathFromUvx(string uvxPath)
103+
{
104+
if (string.IsNullOrWhiteSpace(uvxPath))
105+
{
106+
return uvxPath;
107+
}
108+
109+
string directory = Path.GetDirectoryName(uvxPath);
110+
string extension = Path.GetExtension(uvxPath);
111+
string uvFileName = "uv" + extension;
112+
113+
return string.IsNullOrEmpty(directory)
114+
? uvFileName
115+
: Path.Combine(directory, uvFileName);
116+
}
117+
102118
private string GetPlatformSpecificPathPrepend()
103119
{
104120
if (Application.platform == RuntimePlatform.OSXEditor)

0 commit comments

Comments
 (0)