Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Commit

Permalink
fix: Expand short paths on Windows
Browse files Browse the repository at this point in the history
Sometimes paths on Windows are represented by short paths such
as C:\PROGRA~1. This leads to issues if we try to compare paths
and one of them is equivalent to the other, but shortened.

To solve this issue, try to resolve the long path when resolving
directory paths (which is the only place I've seen this problem
occur so far). It specifically lead to failures on CI where TEMP
directory is a short path.
  • Loading branch information
dividedmind committed Aug 4, 2023
1 parent 4f178f6 commit 7e41bc2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion components/path/node/win32.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { win32 as Win32Path } from "node:path";
import fswin from "fswin";

const {
undefined,
Expand Down Expand Up @@ -70,8 +71,11 @@ export const fromIpcPath = (path) => {
}
};

/* c8 ignore next */
const toLongPath = (path) => fswin?.convertPathSync(path, true) || path;

export const toDirectoryPath = (path) =>
path.endsWith("/") || path.endsWith("\\") ? path : `${path}\\`;
toLongPath(path.endsWith("/") || path.endsWith("\\") ? path : `${path}\\`);

export const toAbsolutePath = (relative, base) => {
const path =
Expand Down
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"ajv-error-tree": "0.0.5",
"astring": "^1.8.4",
"chalk": "^5.0.1",
"fswin": "^3.23.311",
"glob": "^8.0.3",
"htmlparser2": "^8.0.1",
"klaw-sync": "^6.0.0",
Expand Down

0 comments on commit 7e41bc2

Please sign in to comment.