Skip to content

Commit

Permalink
Merge pull request #257 from bramrodenburg/bugfix-yaml-directories
Browse files Browse the repository at this point in the history
Bug fix: ignore folders that look like yaml files.
  • Loading branch information
lyz-code authored Aug 31, 2023
2 parents b81fcd1 + fe45889 commit 7e4aae6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/yamlfix/entrypoints/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _find_all_yaml_files(
file
for list_ in files
for file in list_
if not _matches_any_glob(file, dir_, exclude_globs)
if not _matches_any_glob(file, dir_, exclude_globs) and os.path.isfile(file)
]


Expand Down
10 changes: 10 additions & 0 deletions tests/e2e/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pathlib import Path
from textwrap import dedent

import py # type: ignore
import pytest
from _pytest.logging import LogCaptureFixture
from click.testing import CliRunner
Expand Down Expand Up @@ -410,3 +411,12 @@ def test_std_and_file_error(runner: CliRunner, tmp_path: Path) -> None:
assert (
str(result.exception) == "Cannot specify '-' and other files at the same time."
)


def test_do_not_read_folders_as_files(runner: CliRunner, tmpdir: py.path.local) -> None:
"""Skips folders that have a .yml or .yaml extension."""
tmpdir.mkdir("folder.yml")

result = runner.invoke(cli, [str(tmpdir)])

assert result.exit_code == 0

0 comments on commit 7e4aae6

Please sign in to comment.