Module: Lono::Cfn::Preview::DiffViewer

Included in:
Codediff, Param, Sets::Preview::Codediff
Defined in:
lib/lono/cfn/preview/diff_viewer.rb

Instance Method Summary collapse

Instance Method Details

#diff_viewerObject



14
15
16
17
18
19
20
21
# File 'lib/lono/cfn/preview/diff_viewer.rb', line 14

def diff_viewer
  return ENV['LONO_DIFF'] if ENV['LONO_DIFF']
  colordiff_installed = system("type colordiff > /dev/null 2>&1")
  unless colordiff_installed
    puts "INFO: colordiff it not available. Recommend installing it."
  end
  colordiff_installed ? "colordiff" : "diff"
end

#show_diff(existing_path, new_path) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/lono/cfn/preview/diff_viewer.rb', line 3

def show_diff(existing_path, new_path)
  command = "#{diff_viewer} #{existing_path} #{new_path}"
  puts "Running: #{command}"
  out = `#{command}`
  if out.strip == ''
    puts "There were no differences."
  else
    puts out
  end
end