-
Notifications
You must be signed in to change notification settings - Fork 632
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
walk and walk-sync has problems with absolute paths in certain conditions #1102
Comments
As discussed in discord, intuitively I think we should only use the relative part of the file path (ie: |
Hi @felixsanz The easiest fix is to use console.log([...walkSync("/home/username/articles",{ match: [/\.md/] })]); // WORK
console.log([...walkSync('/home/username/articles', { match: [path.globToRegExp('*.md')] })]) // DOESN'T WORK The issue is related to |
so it's a bug or a feature? |
I agree. I think it makes sense if |
Looked into fs APIs in more details. This scenario is covered nicely by import { expandGlobSync } from "@std/path";
console.log([...expandGlobSync("*.md", { root: "/home/username/articles" })]);
console.log([...expandGlobSync("**/*.md", { root: "/home/username/articles" })]);
console.log([...expandGlobSync("**/*", { root: "/home/username/articles", exclude: ["*.md"] })]); Please use this pattern if you want to look up or skip using globs. I now don't think it's good idea to change |
Describe the bug A clear and concise description of what the bug is.
At least
walk
andwalk-sync
(don't know other functions), has some weird issue.Let's say we have a folder
/home/username/articles/
with a few.md
files inside.And let's create a
wtf.ts
file in that folder with this content:.md
files should be listed in all cases, but when using*.md
and an absolute path, it doesn't list anything. Either use relative path, or I change glob pattern to**/*.md
, which I don't want because it also would walk any subdirectory.For reference:
To Reproduce Steps to reproduce the behavior:
See above
Expected behavior A clear and concise description of what you expected to
happen.
Should list files
Desktop (please complete the following information):
Additional context Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: