mirror of
https://github.com/Hopiu/djLint.git
synced 2026-04-25 07:24:45 +00:00
adds a fix and test for #101
This commit is contained in:
parent
85ed2a89b4
commit
77db0be1c2
4 changed files with 11 additions and 6 deletions
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
|
||||
import logging
|
||||
import re
|
||||
|
||||
## get pyproject.toml settings
|
||||
from pathlib import Path
|
||||
|
|
@ -218,7 +217,7 @@ class Config:
|
|||
|
||||
if extend_exclude:
|
||||
self.exclude += r" | " + r" | ".join(
|
||||
re.escape(x.strip()) for x in extend_exclude.split(",")
|
||||
x.strip() for x in extend_exclude.split(",")
|
||||
)
|
||||
|
||||
# add blank line after load tags
|
||||
|
|
|
|||
|
|
@ -13,8 +13,12 @@ def get_src(src: List[Path], config: Config) -> List[Path]:
|
|||
"""Get source files."""
|
||||
paths = []
|
||||
for item in src:
|
||||
if Path.is_file(item) and no_pragma(config, item):
|
||||
paths.append(item)
|
||||
|
||||
# normalize path
|
||||
normalized_item = Path(item).resolve()
|
||||
|
||||
if Path.is_file(normalized_item) and no_pragma(config, normalized_item):
|
||||
paths.append(normalized_item)
|
||||
continue
|
||||
|
||||
# remove leading . from extension
|
||||
|
|
@ -23,9 +27,9 @@ def get_src(src: List[Path], config: Config) -> List[Path]:
|
|||
|
||||
paths.extend(
|
||||
filter(
|
||||
lambda x: not re.search(config.exclude, str(x), re.VERBOSE)
|
||||
lambda x: not re.search(config.exclude, x.as_posix(), re.VERBOSE)
|
||||
and no_pragma(config, x),
|
||||
list(item.glob(f"**/*.{extension}")),
|
||||
list(normalized_item.glob(f"**/*.{extension}")),
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
1
tests/config_excludes/foo/excluded.html
Normal file
1
tests/config_excludes/foo/excluded.html
Normal file
|
|
@ -0,0 +1 @@
|
|||
<h1>bad</h2>
|
||||
|
|
@ -84,6 +84,7 @@ def test_exclude(runner: CliRunner) -> None:
|
|||
result = runner.invoke(djlint, ["tests/config_excludes"])
|
||||
assert """html.html""" in result.output
|
||||
assert """excluded.html""" not in result.output
|
||||
assert """foo/excluded.html""" not in result.output
|
||||
assert result.exit_code == 1
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue