Merge pull request #102 from avdv/fix-list-hidden-files

Only filter hidden files when listing a directory
This commit is contained in:
Athitya Kumar 2017-08-21 18:12:42 +05:30 committed by GitHub
commit 403f6776a6
4 changed files with 13 additions and 3 deletions

View file

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

View file

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

7
spec/core_spec.rb Normal file
View file

@ -0,0 +1,7 @@
require 'spec_helper'
RSpec.describe ColorLS do
it 'lists info of a hidden file with --long option' do
expect { ColorLS::Flags.new('--long', 'spec/fixtures/.hidden-file').process }.to_not output(/No Info/).to_stdout
end
end

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