mirror of
https://github.com/athityakumar/colorls.git
synced 2024-09-19 05:31:23 +02:00
Merge pull request #102 from avdv/fix-list-hidden-files
Only filter hidden files when listing a directory
This commit is contained in:
commit
403f6776a6
4 changed files with 13 additions and 3 deletions
|
@ -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
|
||||||
|
|
|
@ -43,13 +43,15 @@ 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]
|
@input = File.dirname(path)
|
||||||
|
[File.basename(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
|
||||||
|
|
||||||
|
|
7
spec/core_spec.rb
Normal file
7
spec/core_spec.rb
Normal 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
0
spec/fixtures/.hidden-file
vendored
Normal file
Loading…
Reference in a new issue