Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include limited metadata in 'DirEntry' objects #4941

Merged
merged 2 commits into from
Apr 29, 2020
Merged

Conversation

piscisaureus
Copy link
Member

@piscisaureus piscisaureus commented Apr 27, 2020

For consistency, this PR also modifies std's WalkEntry interface to extend DirEntry with an additional path field.

piscisaureus added a commit to piscisaureus/deno that referenced this pull request Apr 27, 2020
For consistency, this PR also renames the `filename` field in std's
`WalkEntry` interface to just `name`. `WalkEntry` and `DirEntry` now
have identical definitions, although `WalkEntry` contains full paths
whereas `DirEntry` just contains the file name itself.

Closes: denoland#4932
@piscisaureus piscisaureus requested a review from ry April 27, 2020 20:43
std/fs/walk.ts Outdated
return false;
}
return true;
}

export interface WalkEntry {
filename: string;
name: string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it should be path?

piscisaureus added a commit to piscisaureus/deno that referenced this pull request Apr 27, 2020
For consistency, this PR also renames the `filename` field in std's
`WalkEntry` interface to just `name`. `WalkEntry` and `DirEntry` now
have identical definitions, although `WalkEntry` contains full paths
whereas `DirEntry` just contains the file name itself.
@ry ry mentioned this pull request Apr 28, 2020
43 tasks
name: string;
info: FileInfo;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember correctly we want to make stat optional - so this field would be optional as well; is that correct @piscisaureus? If so we should do that before 1.0 as making it info? is breaking change

@@ -73,8 +73,8 @@ export async function* expandGlob(
const excludePatterns = exclude
.map(resolveFromRoot)
.map((s: string): RegExp => globToRegExp(s, globOptions));
const shouldInclude = (filename: string): boolean =>
!excludePatterns.some((p: RegExp): boolean => !!filename.match(p));
const shouldInclude = (name: string): boolean =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why we're changing filename to name...

@ry
Copy link
Member

ry commented Apr 29, 2020

I wonder if we can restrict readdir further and have it return a Iterable<string>... we could just leave the stat operation to users.

Also this API is quite ugly in TypeScript since you have a lot of entry!.info ...

For consistency, this PR also modifies std's `WalkEntry` interface to
extend `DirEntry` with an additional `path` field.
@piscisaureus piscisaureus changed the title Move file metadata in 'DirEntry' to the 'info' field Include limited metadata in 'DirEntry' objects Apr 29, 2020
Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ry ry merged commit 3e6ea62 into denoland:master Apr 29, 2020
@piscisaureus piscisaureus deleted the dirent branch May 1, 2020 23:17
SASUKE40 pushed a commit to SASUKE40/deno that referenced this pull request May 7, 2020
This change is to prevent needed a separate stat syscall for each file
when using readdir.

For consistency, this PR also modifies std's `WalkEntry` interface to
extend `DirEntry` with an additional `path` field.
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 21, 2021
…no#4941)

This change is to prevent needed a separate stat syscall for each file
when using readdir.

For consistency, this PR also modifies std's `WalkEntry` interface to
extend `DirEntry` with an additional `path` field.
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 24, 2021
…no#4941)

This change is to prevent needed a separate stat syscall for each file
when using readdir.

For consistency, this PR also modifies std's `WalkEntry` interface to
extend `DirEntry` with an additional `path` field.
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 24, 2021
…no#4941)

This change is to prevent needed a separate stat syscall for each file
when using readdir.

For consistency, this PR also modifies std's `WalkEntry` interface to
extend `DirEntry` with an additional `path` field.
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 24, 2021
…no#4941)

This change is to prevent needed a separate stat syscall for each file
when using readdir.

For consistency, this PR also modifies std's `WalkEntry` interface to
extend `DirEntry` with an additional `path` field.
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
…no#4941)

This change is to prevent needed a separate stat syscall for each file
when using readdir.

For consistency, this PR also modifies std's `WalkEntry` interface to
extend `DirEntry` with an additional `path` field.
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
…no#4941)

This change is to prevent needed a separate stat syscall for each file
when using readdir.

For consistency, this PR also modifies std's `WalkEntry` interface to
extend `DirEntry` with an additional `path` field.
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
…no#4941)

This change is to prevent needed a separate stat syscall for each file
when using readdir.

For consistency, this PR also modifies std's `WalkEntry` interface to
extend `DirEntry` with an additional `path` field.
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
…no#4941)

This change is to prevent needed a separate stat syscall for each file
when using readdir.

For consistency, this PR also modifies std's `WalkEntry` interface to
extend `DirEntry` with an additional `path` field.
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Feb 1, 2021
…no#4941)

This change is to prevent needed a separate stat syscall for each file
when using readdir.

For consistency, this PR also modifies std's `WalkEntry` interface to
extend `DirEntry` with an additional `path` field.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants