From 804f83828f9b0781e42d053777d7fc3c050fb5e6 Mon Sep 17 00:00:00 2001 From: Crystal Tenn Date: Tue, 18 Apr 2023 17:30:53 -0400 Subject: [PATCH 1/3] fix path reference for reusable workflows and use vscodeURI instead --- languageserver/src/file-provider.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/languageserver/src/file-provider.ts b/languageserver/src/file-provider.ts index cc0ceec..8722901 100644 --- a/languageserver/src/file-provider.ts +++ b/languageserver/src/file-provider.ts @@ -4,6 +4,7 @@ import {fileIdentifier} from "@actions/workflow-parser/workflows/file-reference" import {Octokit} from "@octokit/rest"; import path from "path"; import {TTLCache} from "./utils/cache"; +import vscodeURI from "vscode-uri/lib/umd"; // work around issues with the vscode-uri package export function getFileProvider( client: Octokit | undefined, @@ -31,7 +32,10 @@ export function getFileProvider( throw new Error("Local file references are not supported with this configuration"); } - const file = await readFile(path.join(workspace, ref.path)); + const workspaceURI = vscodeURI.URI.parse(workspace); + const path = vscodeURI.Utils.joinPath(workspaceURI, ref.path); + const file = await readFile(path.toString()); + if (!file) { throw new Error(`File not found: ${ref.path}`); } From dba3cf5d9604a21528896ffe3049a844d7b8f9e0 Mon Sep 17 00:00:00 2001 From: Crystal Tenn Date: Tue, 18 Apr 2023 18:13:52 -0400 Subject: [PATCH 2/3] remove unused reference to path --- languageserver/src/file-provider.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/languageserver/src/file-provider.ts b/languageserver/src/file-provider.ts index 8722901..e97a653 100644 --- a/languageserver/src/file-provider.ts +++ b/languageserver/src/file-provider.ts @@ -2,9 +2,8 @@ import {File} from "@actions/workflow-parser/workflows/file"; import {FileProvider} from "@actions/workflow-parser/workflows/file-provider"; import {fileIdentifier} from "@actions/workflow-parser/workflows/file-reference"; import {Octokit} from "@octokit/rest"; -import path from "path"; import {TTLCache} from "./utils/cache"; -import vscodeURI from "vscode-uri/lib/umd"; // work around issues with the vscode-uri package +import vscodeURI from "vscode-uri/lib/umd"; export function getFileProvider( client: Octokit | undefined, From 2449e5cea1fb18cefd76645ff546b5a1a1d2a125 Mon Sep 17 00:00:00 2001 From: Crystal Tenn Date: Tue, 18 Apr 2023 18:16:55 -0400 Subject: [PATCH 3/3] make variable names more specific --- languageserver/src/file-provider.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/languageserver/src/file-provider.ts b/languageserver/src/file-provider.ts index e97a653..6bed0b1 100644 --- a/languageserver/src/file-provider.ts +++ b/languageserver/src/file-provider.ts @@ -32,8 +32,8 @@ export function getFileProvider( } const workspaceURI = vscodeURI.URI.parse(workspace); - const path = vscodeURI.Utils.joinPath(workspaceURI, ref.path); - const file = await readFile(path.toString()); + const refURI = vscodeURI.Utils.joinPath(workspaceURI, ref.path); + const file = await readFile(refURI.toString()); if (!file) { throw new Error(`File not found: ${ref.path}`);