Support PowerShell and resolve workspaces by directory path

This commit is contained in:
Mohamed Boudra
2026-04-04 15:37:26 +07:00
parent 5d5a79a2a8
commit 449a4b48d2
10 changed files with 323 additions and 17 deletions
+36 -3
View File
@@ -44,6 +44,36 @@ export function resolveWorkspaceIdByExecutionDirectory(input: {
return null;
}
export function resolveWorkspaceMapKeyByIdentity(input: {
workspaces: Map<string, WorkspaceDescriptor> | null | undefined;
workspaceIdentity: string | null | undefined;
}): string | null {
const normalizedWorkspaceIdentity = normalizeWorkspaceIdentity(input.workspaceIdentity);
if (!normalizedWorkspaceIdentity) {
return null;
}
const workspaces = input.workspaces;
if (!workspaces) {
return null;
}
if (workspaces.has(normalizedWorkspaceIdentity)) {
return normalizedWorkspaceIdentity;
}
for (const [workspaceKey, workspace] of workspaces) {
if (
normalizeWorkspaceIdentity(workspace.id) === normalizedWorkspaceIdentity ||
normalizeWorkspaceIdentity(workspace.workspaceDirectory) === normalizedWorkspaceIdentity
) {
return workspaceKey;
}
}
return null;
}
export function getWorkspaceExecutionAuthority(
input:
| {
@@ -58,11 +88,14 @@ export function getWorkspaceExecutionAuthority(
"workspace" in input
? input.workspace
: (() => {
const normalizedWorkspaceId = normalizeWorkspaceIdentity(input.workspaceId);
if (!normalizedWorkspaceId) {
const workspaceKey = resolveWorkspaceMapKeyByIdentity({
workspaces: input.workspaces,
workspaceIdentity: input.workspaceId,
});
if (!workspaceKey) {
return null;
}
return input.workspaces?.get(normalizedWorkspaceId) ?? null;
return input.workspaces?.get(workspaceKey) ?? null;
})();
if ("workspaces" in input) {