Skip to content

Commit

Permalink
Avoid using Dirent.path and Dirent.parentPath since they are not avai…
Browse files Browse the repository at this point in the history
…lable in earlier Node 18.x versions

Dirent.path was added in Node 18.17.0 and then deprecated in Node 18.20.0. Dirent.parentPath was added in Node 18.20.0. In order to keep compatibility with versions of Node before 18.17.0, don't use Dirent.path or Dirent.parentPath.
  • Loading branch information
cmoesel committed Dec 21, 2024
1 parent 808559a commit 52b7f86
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/cache/DiskBasedPackageCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class DiskBasedPackageCache implements PackageCache {
return fs
.readdirSync(contentPath, { withFileTypes: true })
.filter(entry => entry.isFile() && /^[^.].*\.json$/i.test(entry.name))
.map(entry => path.resolve(entry.path, entry.name))
.map(entry => path.resolve(contentPath, entry.name))
.sort();
}

Expand Down
6 changes: 2 additions & 4 deletions src/virtual/DiskBasedVirtualPackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,9 @@ function getFilePaths(paths: string[], recursive: boolean): string[] {
} else if (stat.isDirectory()) {
fs.readdirSync(p, { withFileTypes: true }).forEach(entry => {
if (entry.isFile()) {
filePaths.add(path.resolve(entry.parentPath, entry.name));
filePaths.add(path.resolve(p, entry.name));
} else if (recursive && entry.isDirectory()) {
getFilePaths([path.resolve(entry.parentPath, entry.name)], recursive).forEach(fp =>
filePaths.add(fp)
);
getFilePaths([path.resolve(p, entry.name)], recursive).forEach(fp => filePaths.add(fp));
}
});
}
Expand Down

0 comments on commit 52b7f86

Please sign in to comment.