Skip to content

Commit

Permalink
fix(src): resolve exclude paths
Browse files Browse the repository at this point in the history
  • Loading branch information
antoineauger committed Nov 22, 2024
1 parent 3322497 commit 871a75e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions djlint/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1123,3 +1123,9 @@ def __init__(
)
"""
)

def get_exclude_paths(self) -> list[Path]:
return [
Path(p.strip().replace("\\.", ".")).resolve()
for p in self.exclude.split("|")
]
2 changes: 1 addition & 1 deletion djlint/src.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def get_src(src: Iterable[Path], config: Config) -> list[Path]:
paths.extend(
x
for x in normalized_item.glob(f"**/*.{extension}")
if not re.search(config.exclude, x.as_posix(), flags=re.X)
if not any(x.is_relative_to(p) for p in config.get_exclude_paths())
and no_pragma(config, x)
and (
(config.use_gitignore and not config.gitignore.match_file(x))
Expand Down
4 changes: 2 additions & 2 deletions tests/test_config/test_excludes/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[tool.djlint]
exclude = "foo/excluded.html"
extend_exclude = "excluded.html"
exclude = "tests/test_config/test_excludes/foo/excluded.html"
extend_exclude = "tests/test_config/test_excludes/excluded.html"

0 comments on commit 871a75e

Please sign in to comment.