Only filter hidden files when listing a directory

* add `.hidden-file` to fixtures
* add check that `.hidden-file` is found to .travis.yml

Fixes #101.
This commit is contained in:
Claudio Bley 2017-08-17 19:29:13 +02:00
parent ae751cc896
commit 6fa9ca2112
3 changed files with 4 additions and 2 deletions

View file

@ -19,6 +19,7 @@ script:
- colorls -f - colorls -f
- colorls -l - colorls -l
- colorls -l spec/fixtures/symlinks - colorls -l spec/fixtures/symlinks
- ( cd spec/fixtures ; colorls .hidden-file ) | fgrep '.hidden-file'
- colorls -l README.md - colorls -l README.md
- colorls -r - colorls -r
- colorls -sd - colorls -sd

View file

@ -43,13 +43,14 @@ module ColorLS
private private
def init_contents(path) def init_contents(path)
@contents = if Dir.exist?(path) is_directory = Dir.exist?(path)
@contents = if is_directory
Dir.entries(path) Dir.entries(path)
else else
[path] [path]
end end
filter_hidden_contents filter_hidden_contents if is_directory
filter_contents(path) if @show filter_contents(path) if @show
sort_contents(path) if @sort sort_contents(path) if @sort

0
spec/fixtures/.hidden-file vendored Normal file
View file