@jsenv/filesystem 2.7.0 → 2.7.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/filesystem",
3
- "version": "2.7.0",
3
+ "version": "2.7.1",
4
4
  "description": "Collection of functions to interact with filesystem in Node.js",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -19,12 +19,20 @@ export const getRealFileSystemUrlSync = (
19
19
  while (true) {
20
20
  const name = parts[i]
21
21
  i++
22
- const namesOnFileSystem = readdirSync(
23
- // When Node.js receives "C:/" on windows it returns
24
- // the process.cwd() directory content...
25
- // This can be fixed by passing "file:///C:/" directly but as a url object
26
- new URL(reconstructedFileUrl),
27
- )
22
+ let namesOnFileSystem
23
+ try {
24
+ namesOnFileSystem = readdirSync(
25
+ // When Node.js receives "C:/" on windows it returns
26
+ // the process.cwd() directory content...
27
+ // This can be fixed by passing "file:///C:/" directly but as a url object
28
+ new URL(reconstructedFileUrl),
29
+ )
30
+ } catch (e) {
31
+ if (e && e.code === "ENOENT") {
32
+ return null
33
+ }
34
+ throw e
35
+ }
28
36
  const foundOnFilesystem = namesOnFileSystem.includes(name)
29
37
  if (foundOnFilesystem) {
30
38
  reconstructedFileUrl += name
@@ -32,6 +40,9 @@ export const getRealFileSystemUrlSync = (
32
40
  const nameOnFileSystem = namesOnFileSystem.find(
33
41
  (nameCandidate) => nameCandidate.toLowerCase() === name.toLowerCase(),
34
42
  )
43
+ if (!nameOnFileSystem) {
44
+ return null
45
+ }
35
46
  reconstructedFileUrl += nameOnFileSystem
36
47
  }
37
48
  if (i === parts.length) {