@bytecodealliance/preview2-shim 0.27.1 → 0.28.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.
@@ -11,6 +11,23 @@ const MAX_SYMLINKS = 40;
11
11
  function normalizeHostPath(path) {
12
12
  return isWindows ? path.replace(/\\/g, "/") : path;
13
13
  }
14
+ /**
15
+ * Resolve symlinks in a host path.
16
+ *
17
+ * Node's realpathSync() cannot walk namespaced Windows paths (`\\?\C:\...`): it
18
+ * stats the namespace root (`\\?\C:`), which is a volume rather than a directory
19
+ * and fails with EISDIR. Drive and UNC paths resolve the same without the prefix.
20
+ */
21
+ function realHostPath(path) {
22
+ if (isWindows) {
23
+ path = path
24
+ .replace(/^[\\/]{2}\?[\\/]UNC[\\/]/i, "//")
25
+ .replace(/^[\\/]{2}\?[\\/]([a-zA-Z]:)(?=[\\/]|$)/, "$1")
26
+ // A bare drive would otherwise resolve against that drive's cwd
27
+ .replace(/^([a-zA-Z]:)$/, "$1/");
28
+ }
29
+ return normalizeHostPath(realpathSync(path));
30
+ }
14
31
  const nsMagnitude = 1000000000n;
15
32
  function nsToDateTime(ns) {
16
33
  const seconds = ns / nsMagnitude;
@@ -598,7 +615,7 @@ class Descriptor {
598
615
  }
599
616
  let baseResolved;
600
617
  try {
601
- baseResolved = normalizeHostPath(realpathSync(base));
618
+ baseResolved = realHostPath(base);
602
619
  }
603
620
  catch (error) {
604
621
  throw convertFsError(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytecodealliance/preview2-shim",
3
- "version": "0.27.1",
3
+ "version": "0.28.0",
4
4
  "description": "WASI Preview2 shim for JS environments",
5
5
  "homepage": "https://github.com/bytecodealliance/jco#readme",
6
6
  "bugs": {