Class: Wordmove::Hook::Local

Inherits:
Object
  • Object
show all
Defined in:
lib/wordmove/hook.rb

Class Method Summary collapse

Class Method Details

.loggerObject



80
81
82
# File 'lib/wordmove/hook.rb', line 80

def self.logger
  Wordmove::Hook.logger
end

.run(command_hash, options, simulate = false) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/wordmove/hook.rb', line 84

def self.run(command_hash, options, simulate = false)
  wordpress_path = options[:wordpress_path]

  logger.task_step true, "Exec command: #{command_hash[:command]}"
  return true if simulate

  stdout_return = `cd #{wordpress_path} && #{command_hash[:command]} 2>&1`
  logger.task_step true, "Output: #{stdout_return}"

  if $CHILD_STATUS.exitstatus.zero?
    logger.success ""
  else
    logger.error "Error code: #{$CHILD_STATUS.exitstatus}"
    raise Wordmove::LocalHookException unless command_hash[:raise].eql? false
  end
end