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

Exclude function needs better docs or changes #31

Closed
razzeee opened this issue May 18, 2020 · 3 comments
Closed

Exclude function needs better docs or changes #31

razzeee opened this issue May 18, 2020 · 3 comments

Comments

@razzeee
Copy link

razzeee commented May 18, 2020

https://github.com/thecodrr/fdir/blob/master/documentation.md#excludefunction

Seems to suggest, that you only match on the deepest folder, but it doesn't it seems to hand you the complete path to match on. It also seems to change depending on other parameters.

 const elmJsonGlob = `${globUri}/**/elm.json`;

      let x = new fdir()
        .glob(elmJsonGlob)
        .exclude(
          (dir) =>
            dir.startsWith(".") ||
            dir === "node_modules" ||
            dir === "elm-stuff",
        )
        .crawl(".")
        .sync();

this will lead to dir in the exclude function being something like ./path/.git/file

 const elmJsonGlob = `${globUri}/**/elm.json`;

      let x = new fdir()
        .glob(elmJsonGlob)
        .exclude(
          (dir) =>
            dir.startsWith(".") ||
            dir === "node_modules" ||
            dir === "elm-stuff",
        )
        .withFullPaths()
        .crawl(".")
        .sync();

this will lead to dir in the exclude function being something like home/razze/Development/elm-pages-starter/node_modules/chalk on linux

I feel like that would at least need to be pointed out.

@thecodrr
Copy link
Owner

Good idea! I will make it more clear in the docs.

Also in this example:

      let x = new fdir()
        .glob(elmJsonGlob)
        .exclude(
          (dir) =>
            dir.startsWith(".") ||
            dir === "node_modules" ||
            dir === "elm-stuff",
        )
        .crawl(".")
        .sync();

dir would be something like file or node_modules unless you add withBasePath.

@razzeee
Copy link
Author

razzeee commented May 19, 2020

Are you sure? I actually debugged into it and saw those example paths. It's not node_modules or file it's always the complete path as in ./node_modules/fdir/api/file as far as I can see.

I think changing the api would be better, most usecases probably just want to match the next folder we're traversing into, not the complete path. If that's possible at all.

@thecodrr
Copy link
Owner

Yeah, I was thinking the same. I will make the changes.

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

No branches or pull requests

2 participants