Class: Wordmove::Hook::Local

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

Class Method Summary collapse

Class Method Details

.loggerObject



68
69
70
# File 'lib/wordmove/hook.rb', line 68

def self.logger
  parent.logger
end

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



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/wordmove/hook.rb', line 72

def self.run(hooks, options, simulate = false)
  logger.task "Running local hooks"

  wordpress_path = options[:wordpress_path]

  hooks.each do |hook|
    logger.task_step true, "Exec command: #{hook[:command]}"
    return true if simulate

    stdout_return = `cd #{wordpress_path} && #{hook[: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 hook[:raise].eql? false
    end
  end
end