git-tm 1.1.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/paths.js ADDED
@@ -0,0 +1,21 @@
1
+ // Comparing file system paths that may be spelled differently but name the same folder:
2
+ // symlinks (macOS /tmp is /private/tmp) and Windows drive-letter or name casing (c:\ vs C:\).
3
+ // Internal: not part of the package's public exports.
4
+
5
+ import { realpath } from "node:fs/promises";
6
+ import path from "node:path";
7
+
8
+ /** The canonical form of a path: symlinks resolved when the path exists, otherwise just resolved. */
9
+ export async function canonicalPath(p) {
10
+ try {
11
+ return await realpath(p);
12
+ } catch {
13
+ return path.resolve(p);
14
+ }
15
+ }
16
+
17
+ /** Whether two canonical paths are the same. Windows file systems ignore case. */
18
+ export function samePath(a, b, platform = process.platform) {
19
+ const norm = (p) => (platform === "win32" ? path.win32.normalize(p).toLowerCase() : p);
20
+ return norm(a) === norm(b);
21
+ }