Support glob patterns in files.included/files.excluded#175
Open
fschoenfeldt wants to merge 1 commit into
Open
Conversation
`quokka.files.excluded`/`included` only matched via `String.starts_with?` on the relative path, so glob patterns such as `"config/*.exs"` silently matched nothing while looking like the globs used by `mix format`'s `:inputs`. Users had to discover that only bare directory prefixes work. Expand each entry with `Path.wildcard/2` (mirroring how `mix format` resolves `:inputs`/`:excludes`) into a cwd-relative MapSet, and match a file if it is either prefixed by an entry (legacy behaviour, kept for bare dir prefixes like `"config/"`) or a member of the expanded set. Fully backward compatible. Fixes emkguts#174 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
s3cur3
approved these changes
Jun 30, 2026
Comment on lines
+204
to
+209
| test "exclusion wins over inclusion" do | ||
| assert :ok = set!(quokka: [files: %{included: ["lib/**/*.ex"], excluded: ["lib/quokka/*.ex"]}]) | ||
|
|
||
| refute Quokka.Config.allowed_directory?("lib/quokka/config.ex") | ||
| assert Quokka.Config.allowed_directory?("lib/styler.ex") | ||
| end |
| defp expand_file_globs(patterns) do | ||
| patterns | ||
| |> List.wrap() | ||
| |> Enum.flat_map(&Path.wildcard(Path.expand(&1, File.cwd!()), match_dot: true)) |
Collaborator
There was a problem hiding this comment.
Do we gain anything from doing the expansion? I'm not sure we do. If there would be duplicates, I think doing the MapSet relative to the current working directory would take care of them, right?
Suggested change
| |> Enum.flat_map(&Path.wildcard(Path.expand(&1, File.cwd!()), match_dot: true)) | |
| |> Enum.flat_map(&Path.wildcard(&1, match_dot: true)) |
Collaborator
|
@fschoenfeldt, wanna merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
quokka.files.excluded/includedonly matched viaString.starts_with?on the relative path, so glob patterns such as"config/*.exs"silently matched nothing while looking like the globs used bymix format's:inputs. Users had to discover that only bare directory prefixes work.Expand each entry with
Path.wildcard/2(mirroring howmix formatresolves:inputs/:excludes) into a cwd-relative MapSet, and match a file if it is either prefixed by an entry (legacy behaviour, kept for bare dir prefixes like"config/") or a member of the expanded set. Fully backward compatible.resolves #174
Authored with assistance from Claude Code.
PR Checklist
/docs/*.mdfilemix formatand committed any changes