mirror of
https://github.com/athityakumar/colorls.git
synced 2024-09-12 05:31:14 +02:00
Fix long listing of files as arguments
The elements in `@contents` should only ever be names of directory entries. Otherwise erroneous paths will be constructed with `@input/@content_entry`. * add check to ensure that long listing prints information about `.hidden-file` Fixes #104.
This commit is contained in:
parent
6fa9ca2112
commit
438aed19bd
2 changed files with 9 additions and 1 deletions
|
@ -47,7 +47,8 @@ module ColorLS
|
|||
@contents = if is_directory
|
||||
Dir.entries(path)
|
||||
else
|
||||
[path]
|
||||
@input = File.dirname(path)
|
||||
[File.basename(path)]
|
||||
end
|
||||
|
||||
filter_hidden_contents if is_directory
|
||||
|
|
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
|
Loading…
Reference in a new issue