From 8446cf07dc0c4bce502925b442f9e4f74031faf5 Mon Sep 17 00:00:00 2001 From: Meghan Morrow <129645384+STUzhy@users.noreply.github.com> Date: Thu, 19 Jun 2025 10:55:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E5=8C=BA=E9=AA=8C=E8=AF=81=E4=BB=A5=E9=98=B2?= =?UTF-8?q?=E6=AD=A2.openmcp=E7=9B=AE=E5=BD=95=E5=88=9B=E5=BB=BA=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在getWorkspaceConnectionConfigPath()中添加工作区路径验证 - 在getWorkspaceConnectionConfig()中添加工作区路径验证 - 当没有找到工作区时抛出描述性错误 - 解决VSCode扩展尝试创建.openmcp目录时的ENOENT错误 --- src/global.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/global.ts b/src/global.ts index 07fe34c..c46e6b0 100644 --- a/src/global.ts +++ b/src/global.ts @@ -95,6 +95,9 @@ export function getConnectionConfig() { */ export function getWorkspaceConnectionConfigPath() { const workspace = getWorkspacePath(); + if (!workspace) { + throw new Error('No workspace found. Please open a folder in VSCode first.'); + } const configDir = fspath.join(workspace, '.openmcp'); if (!fs.existsSync(configDir)) { fs.mkdirSync(configDir, { recursive: true }); // 递归创建目录 @@ -113,6 +116,9 @@ export function getWorkspaceConnectionConfig() { } const workspace = getWorkspacePath(); + if (!workspace) { + throw new Error('No workspace found. Please open a folder in VSCode first.'); + } const configDir = fspath.join(workspace, '.openmcp'); const connectionConfig = fspath.join(configDir, CONNECTION_CONFIG_NAME);