Skip to content

Commit

Permalink
Extra debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
fpoli committed Feb 23, 2024
1 parent ceca726 commit 6230210
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/test/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ function workspacePath(): string {
* @returns The computed relative path.
*/
function asRelativeWorkspacePath(target: vscode.Uri): string {
// Sometimes, but not always, some paths on MacOS GitHub runners start with "/private/".
// This might be due to hardlinks in GitHub runners, that are difficult to normalize.
// So, we manually remove the "/private/" prefix if it is present.
if (target.fsPath.startsWith("/private/")) {
return vscode.workspace.asRelativePath(target.fsPath.slice(8));
}
return vscode.workspace.asRelativePath(target);
// Resolve symlinks (especially on MacOS, where `/private/var` is used for `/var`).
// We do this manually becase `vscode.workspace.asRelativePath` does not resolve symlinks.
const normalizedTarget = fs.realpathSync(target.fsPath);
const normalizedWorkspace = fs.realpathSync(workspacePath());
const relative = path.relative(normalizedWorkspace, normalizedTarget).replace(/\\/g, "/");
console.log(`Target path: ${normalizedTarget}`);
console.log(`Workspace path: ${normalizedWorkspace}`);
console.log(`Relative path: ${relative}`);
return relative;
}

/**
Expand Down

0 comments on commit 6230210

Please sign in to comment.