Check if symlink is a file or directory (#758)

pull/762/head
Joe Krill 2024-02-26 10:29:13 -05:00 committed by GitHub
parent 1e30bb29bd
commit 90385f4d4f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 2 deletions

View File

@ -163,11 +163,22 @@ async function* walkPreserveSymlinks(
// Skip hidden files and folders
continue;
}
if (dirEntry.isFile) {
let entry: Deno.DirEntry | Deno.FileInfo = dirEntry;
if (dirEntry.isSymlink) {
try {
entry = await Deno.stat(fullPath);
} catch (e) {
console.error("Error reading symlink", fullPath, e.message);
}
}
if (entry.isFile) {
yield { path: fullPath, entry: dirEntry };
}
if (dirEntry.isDirectory || dirEntry.isSymlink) {
if (entry.isDirectory) {
// If it's a directory or a symlink, recurse into it
yield* walkPreserveSymlinks(fullPath);
}