Module: Wip::CommandDisplay

Defined in:
lib/wip/command_display.rb

Overview

Renders a command array for debug output, masking -e KEY=value env values so secrets from wip.yml never reach logs.

Class Method Summary collapse

Class Method Details

.for_debug(command) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/wip/command_display.rb', line 9

def self.for_debug(command)
  masked = command.each_cons(2).with_index.each_with_object(command.dup) do |((flag, pair), index), result|
    next unless flag == '-e'

    key, = pair.split('=', 2)
    result[index + 1] = "#{key}=***"
  end
  Shellwords.join(masked)
end