mirror of
https://github.com/Hopiu/djLint.git
synced 2026-04-21 13:44:42 +00:00
added fix for #151
This commit is contained in:
parent
65dffd7b3e
commit
8ff71789be
2 changed files with 8 additions and 7 deletions
|
|
@ -68,8 +68,9 @@ def print_output(
|
|||
|
||||
def build_relative_path(url: str, project_root: Path) -> str:
|
||||
"""Get path relative to project."""
|
||||
if project_root != url:
|
||||
return str(Path(url).relative_to(project_root.resolve()))
|
||||
url_path = Path(url)
|
||||
if project_root != url_path and project_root in url_path.parents:
|
||||
return str(url_path.relative_to(project_root.resolve()))
|
||||
|
||||
return url
|
||||
|
||||
|
|
@ -85,7 +86,7 @@ def build_output(error: dict, config: Config) -> int:
|
|||
return 0
|
||||
|
||||
echo(
|
||||
f"{Fore.GREEN}{Style.BRIGHT}\n{build_relative_path(list(error.keys())[0],config.project_root)}\n{Style.DIM}"
|
||||
f"{Fore.GREEN}{Style.BRIGHT}\n{build_relative_path(list(error.keys())[0],config.project_root.resolve())}\n{Style.DIM}"
|
||||
+ "".join(["─" for x in range(1, width)])
|
||||
+ Style.RESET_ALL
|
||||
)
|
||||
|
|
@ -121,7 +122,7 @@ def build_check_output(errors: dict, config: Config) -> int:
|
|||
echo(
|
||||
Fore.GREEN
|
||||
+ Style.BRIGHT
|
||||
+ build_relative_path(list(errors.keys())[0], config.project_root)
|
||||
+ build_relative_path(list(errors.keys())[0], config.project_root.resolve())
|
||||
+ str(list(errors.keys())[0])
|
||||
+ Style.DIM
|
||||
+ Style.RESET_ALL
|
||||
|
|
@ -132,7 +133,7 @@ def build_check_output(errors: dict, config: Config) -> int:
|
|||
Fore.GREEN
|
||||
+ Style.BRIGHT
|
||||
+ "\n"
|
||||
+ build_relative_path(list(errors.keys())[0], config.project_root)
|
||||
+ build_relative_path(list(errors.keys())[0], config.project_root.resolve())
|
||||
+ "\n"
|
||||
+ Style.DIM
|
||||
+ "".join(["─" for x in range(1, width)])
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ run::
|
|||
|
||||
for a single test, run::
|
||||
|
||||
pytest tests/test_config.py::test_exclude --cov=src/djlint \
|
||||
pytest tests/test_config.py::test_indent --cov=src/djlint \
|
||||
--cov-branch --cov-report xml:coverage.xml --cov-report term-missing
|
||||
|
||||
"""
|
||||
|
|
@ -50,7 +50,7 @@ def test_ignores(runner: CliRunner) -> None:
|
|||
|
||||
def test_indent(runner: CliRunner) -> None:
|
||||
result = runner.invoke(djlint, ["tests/config_indent", "--check"])
|
||||
|
||||
print(result.output)
|
||||
assert (
|
||||
"""-<section><p><div><span></span></div></p></section>
|
||||
+<section>
|
||||
|
|
|
|||
Loading…
Reference in a new issue