Fixes empty dir bug (#46)

* Add entry to files.yaml to handle .log file

* Update files.yaml, correcting a typo in log entry

* Update on core.rb, to check if the directory is empty

* Update on core.rb, rewrote test, because Travis saw it as an offense

* Update on core.rb, typo in my test

* Update core.rb, switch error message on empty folder
This commit is contained in:
Paulo 2017-07-09 11:05:18 +02:00 committed by Athitya Kumar
parent 0e2cbc852e
commit 52819d3e93
2 changed files with 10 additions and 6 deletions

View file

@ -17,11 +17,15 @@ module ColorLS
end end
def ls def ls
@contents = chunkify if @contents.empty?
@max_widths = @contents.transpose.map { |c| c.map(&:length).max } print "Nothing to show here\n".colorize(:yellow)
@contents.each { |chunk| ls_line(chunk) } else
print "\n" @contents = chunkify
display_report if @report @max_widths = @contents.transpose.map { |c| c.map(&:length).max }
@contents.each { |chunk| ls_line(chunk) }
print "\n"
display_report if @report
end
true true
end end
@ -30,7 +34,6 @@ module ColorLS
def init_contents def init_contents
@contents = Dir.entries(@input) - %w[. ..] @contents = Dir.entries(@input) - %w[. ..]
@contents.keep_if { |x| !x.start_with? '.' } unless @all @contents.keep_if { |x| !x.start_with? '.' } unless @all
filter_contents if @show filter_contents if @show
sort_contents if @sort sort_contents if @sort

View file

@ -30,6 +30,7 @@ java: "\ue204"
js: "\ue74e" js: "\ue74e"
json: "\ue60b" json: "\ue60b"
less: "\ue758" less: "\ue758"
log: "\uf18d"
lua: "\ue620" lua: "\ue620"
md: "\uf48a" md: "\uf48a"
mustache: "\ue60f" mustache: "\ue60f"