Closed BernH4 closed 1 year ago
Sorry for the confusing UI/UX here. The exclude paths are globs themselves, and we test if the glob expansion from the path matches the glob in the exclude. So in this case, we are checking if the glob first.txt
matches test/first.txt
, which it does not. If you put test/first.txt
and test/second.txt
as the two exclude files, i.e.:
- link:
~/test/:
path: test/*
exclude: [test/first.txt, test/second.txt]
glob: true
Then it should work.
I think this is confusing; intuitively, you might expect the exclude patterns to match against the *
from the glob, not the entire glob? In any case, this should be clarified in the README, and perhaps we can consider changing the behavior here as well.
Hope this solves your immediate problem, and would appreciate hearing any thoughts you have on this matter.
you might expect the exclude patterns to match against the
*
from the glob, not the entire glob?
Yes, thats how i thought it would behave and in I think that would be better than the current solution. I don't see any disadvantage changing that but Im not sure if i understand completely how it works.
The solution you gave me works, but i still have problems excluding directories.
- link:
~/test/:
path: test/*
exclude: [test/not_wanted_dir]
glob: true
Gives me the error:
No wildcard in glob, directory use undefined: ~/test/ -> ['test/some_other_file_in_test_dir]
Did you want to link the directory or into it?
Adding a trailing slash to the dir:
exclude: [test/not_wanted_dir/]
will ignore the exclude completely, which probably makes sense.
How can I solve this? I thought it would work exactly like files do, by just mentioning their name (without trailing slash).
Also because you asked my about my opinion: I maybe miss something but why is it necessary to define a specific path again? If had not read any documentation i would expect to behave like that:
- link:
~/test/:
exclude: [not_wanted_dir, not_wanted_file, dir_inside_test/*.build]
Everthing written inside exclude should be relative to the directory mentioned above (here test/)
While writing this i think i know now the reason, its probably if you dont want to exclude, its if you want to only include files matching a glob right?
Your first example works, when there are files to include. I think the error message is confusing/wrong in that setting, it should have instead been a warning that there are no files that match that combo of glob + exclude.
If I have this directory structure:
test
├── a
├── b
└── not_wanted_dir
└── foo
And this config:
- link:
~/test:
path: test/*
exclude: [test/not_wanted_dir]
glob: true
I get the intended results, with a
and b
being linked, but not the directory.
You don't need to specify things like dir_inside_test/*.build
, because the glob/link is not recursive.
Thanks for your help, got it working :)
Docs added in 9f8fd76. Thanks again for pointing this out.
I tried the following:
But it keeps adding everything in the directory.
I also tried:
Its probably some basic thing but i cant figure it out, thanks.