diff --git a/bin/git-format-staged b/bin/git-format-staged index faa78af..f325ac3 100755 --- a/bin/git-format-staged +++ b/bin/git-format-staged @@ -57,7 +57,7 @@ parser = OptionParser.new do |opt| puts FormatStaged::VERSION exit end - + opt.on('--[no-]color', 'Colorizes output') do |value| parameters[:color_output] = value end diff --git a/format-staged.gemspec b/format-staged.gemspec index ac7abdc..6711751 100644 --- a/format-staged.gemspec +++ b/format-staged.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |s| s.homepage = 'https://github.com/5sw/format-staged' s.license = 'MIT' s.required_ruby_version = '~> 2.7' - + s.add_dependency 'colorize' s.add_development_dependency 'rake', '~> 13.0' diff --git a/lib/format-staged/io.rb b/lib/format-staged/io.rb index df472e3..c7cdaf5 100644 --- a/lib/format-staged/io.rb +++ b/lib/format-staged/io.rb @@ -31,15 +31,15 @@ class FormatStaged [pid, r] end - def read_output(r, lines: true, silent: false) - result = r.read + def read_output(output, lines: true, silent: false) + result = output.read splits = result.split("\n") if @verbose && !silent splits.each do |line| puts "< #{line}" end end - r.close + output.close lines ? splits : result end