mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
feat(std/fs): Re-enable followSymlinks
on walk()
(#8479)
This commit is contained in:
parent
acdfc71d00
commit
7a4d0fc22b
2 changed files with 10 additions and 12 deletions
|
@ -106,18 +106,17 @@ export async function* walk(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for await (const entry of Deno.readDir(root)) {
|
for await (const entry of Deno.readDir(root)) {
|
||||||
|
assert(entry.name != null);
|
||||||
|
let path = join(root, entry.name);
|
||||||
|
|
||||||
if (entry.isSymlink) {
|
if (entry.isSymlink) {
|
||||||
if (followSymlinks) {
|
if (followSymlinks) {
|
||||||
// TODO(ry) Re-enable followSymlinks.
|
path = await Deno.realPath(path);
|
||||||
throw new Error("unimplemented");
|
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(entry.name != null);
|
|
||||||
const path = join(root, entry.name);
|
|
||||||
|
|
||||||
if (entry.isFile) {
|
if (entry.isFile) {
|
||||||
if (includeFiles && include(path, exts, match, skip)) {
|
if (includeFiles && include(path, exts, match, skip)) {
|
||||||
yield { path, ...entry };
|
yield { path, ...entry };
|
||||||
|
@ -159,17 +158,17 @@ export function* walkSync(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (const entry of Deno.readDirSync(root)) {
|
for (const entry of Deno.readDirSync(root)) {
|
||||||
|
assert(entry.name != null);
|
||||||
|
let path = join(root, entry.name);
|
||||||
|
|
||||||
if (entry.isSymlink) {
|
if (entry.isSymlink) {
|
||||||
if (followSymlinks) {
|
if (followSymlinks) {
|
||||||
throw new Error("unimplemented");
|
path = Deno.realPathSync(path);
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(entry.name != null);
|
|
||||||
const path = join(root, entry.name);
|
|
||||||
|
|
||||||
if (entry.isFile) {
|
if (entry.isFile) {
|
||||||
if (includeFiles && include(path, exts, match, skip)) {
|
if (includeFiles && include(path, exts, match, skip)) {
|
||||||
yield { path, ...entry };
|
yield { path, ...entry };
|
||||||
|
|
|
@ -252,12 +252,11 @@ testWalk(
|
||||||
async function symlink(): Promise<void> {
|
async function symlink(): Promise<void> {
|
||||||
assertReady(6);
|
assertReady(6);
|
||||||
const files = await walkArray("a");
|
const files = await walkArray("a");
|
||||||
assertEquals(files.length, 2);
|
assertEquals(files.length, 3);
|
||||||
assert(!files.includes("a/bb/z"));
|
assert(!files.includes("a/bb/z"));
|
||||||
|
|
||||||
const arr = await walkArray("a", { followSymlinks: true });
|
const arr = await walkArray("a", { followSymlinks: true });
|
||||||
assertEquals(arr.length, 3);
|
assertEquals(arr.length, 5);
|
||||||
assert(arr.some((f): boolean => f.endsWith("/b/z")));
|
assert(arr.some((f): boolean => f.endsWith("/b/z")));
|
||||||
},
|
},
|
||||||
true,
|
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue