Skip to content

Commit

Permalink
Merge pull request #197 from ryotarai/show-diff-on-edit-action
Browse files Browse the repository at this point in the history
Show diff on edit action of file resource in dry-run mode.
  • Loading branch information
ryotarai committed Mar 6, 2016
2 parents b520cb8 + b3b3c2a commit cadd381
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/itamae/resource/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class File < Base
define_attribute :block, type: Proc, default: proc {}

def pre_action
current.exist = run_specinfra(:check_file_is_file, attributes.path)

case @current_action
when :create
attributes.exist = true
Expand All @@ -20,7 +22,7 @@ def pre_action
when :edit
attributes.exist = true

unless runner.dry_run?
if !runner.dry_run? || current.exist
content = backend.receive_file(attributes.path)
attributes.block.call(content)
attributes.content = content
Expand All @@ -31,8 +33,6 @@ def pre_action
end

def set_current_attributes
current.exist = run_specinfra(:check_file_is_file, attributes.path)

if current.exist
current.mode = run_specinfra(:get_file_mode, attributes.path).stdout.chomp
current.owner = run_specinfra(:get_file_owner_user, attributes.path).stdout.chomp
Expand Down

0 comments on commit cadd381

Please sign in to comment.