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

Please add { dot: true, matchBase: true } to minimatch options #35

Closed
phil-lgr opened this issue Aug 31, 2021 · 4 comments
Closed

Please add { dot: true, matchBase: true } to minimatch options #35

phil-lgr opened this issue Aug 31, 2021 · 4 comments

Comments

@phil-lgr
Copy link

phil-lgr commented Aug 31, 2021

Steps to reproduce this issue:

Set excluded_globs: "**/node_modules/**,**/dist/**,**/lib/**,**/built/**,**/public/**,**/.cache/**" to exclude nested files in a monorepo

Like this

      - name: Update diagram
        uses: githubocto/repo-visualizer@main
        with:
          commit_message: "chore(core): update diagram"
          output_file: "docs/assets/images/core-repo-diagram.svg"
          excluded_globs: "**/node_modules/*,**/dist/*,**/lib/*,**/built/*,**/public/*,**/.cache/*"
          excluded_paths: "node_modules,dist,lib,built,.cache,public,out,build,.yarn,.vscode,package-lock.json,yarn.lock"

Expected

E.g. files inside /packages/*/.cache are ignored

Actual behavior

files inside /packages/*/.cache are not ignored by minimatch


There is a bunch of bugs with the default minimatch options

Minimatch options:

Related issues:

@phil-lgr
Copy link
Author

phil-lgr commented Aug 31, 2021

with micromatch.isMatch(args.path, args.pattern, { dot: true, matchBase: true }) I think it would exclude what people expect

OR

remove the './' before matching with minimatch

I thinkg the only workaround right now is to match:

image

the ./ before like this:

\.\/**/.cache/**/*.json

in config:

excluded_globs: "\./**/node_modules/**/*,\./**/dist/**/*,\./**/lib/**/*,\./**/built/**/*,\./**/public/**/*,\./**/.cache/**/*"

Edit: no need to escape backslash in yaml

@phil-lgr
Copy link
Author

phil-lgr commented Aug 31, 2021

Actually this does not work either, I think the best solution is to remove the ./ prefix

    const format = (str: string) => str.replace(/^\.\//, '');
    const result = micromatch.isMatch(args.path, args.pattern, { format });

Or use this:

          excluded_globs: "(./)?**/node_modules/**/*;(./)?**/dist/**/*;(./)?**/lib/**/*;(./)?**/built/**/*;(./)?**/public/**/*;(./)?**/.cache/**/*"

@phil-lgr
Copy link
Author

Even with the above glob, I am unable to exclude .cache files and .node_modules in a monorepository :(

image

@Wattenberger
Copy link
Contributor

thanks for digging into this! I think my update should do the trick - let me know if you have any unsolved cases!

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