Add colorize gem + cli option
This commit is contained in:
parent
33c5566838
commit
bb0a3a80c4
5 changed files with 13 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'English'
|
||||
|
||||
class FormatStaged
|
||||
def get_output(*args, lines: true, silent: false)
|
||||
puts "> #{args.join(' ')}" if @verbose
|
||||
|
|
|
@ -5,18 +5,21 @@ require 'format-staged/version'
|
|||
require 'format-staged/entry'
|
||||
require 'format-staged/io'
|
||||
require 'shellwords'
|
||||
require 'colorize'
|
||||
|
||||
##
|
||||
# Runs staged changes through a formatting tool
|
||||
class FormatStaged
|
||||
attr_reader :formatter, :patterns, :update, :write, :verbose
|
||||
|
||||
def initialize(formatter:, patterns:, update: true, write: true, verbose: true)
|
||||
def initialize(formatter:, patterns:, update: true, write: true, verbose: true, color_output: nil)
|
||||
@formatter = formatter
|
||||
@patterns = patterns
|
||||
@update = update
|
||||
@write = write
|
||||
@verbose = verbose
|
||||
|
||||
String.disable_colorization = !(color_output || STDOUT.isatty)
|
||||
end
|
||||
|
||||
def run
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue