Class: Wordmove::Hook::Remote

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

Class Method Summary collapse

Class Method Details

.loggerObject



89
90
91
# File 'lib/wordmove/hook.rb', line 89

def self.logger
  parent.logger
end

.run(commands, ssh_options, simulate = false) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/wordmove/hook.rb', line 93

def self.run(commands, ssh_options, simulate = false)
  logger.task "Running remote hooks"

  copier = Photocopier::SSH.new(ssh_options).tap { |c| c.logger = logger }
  commands.each do |command|
    logger.task_step false, "Exec command: #{command}"
    return true if simulate

    stdout, stderr, exit_code = copier.exec! command

    if exit_code.zero?
      logger.task_step false, "Output: #{stdout}"
      logger.success ""
    else
      logger.task_step false, "Output: #{stderr}"
      logger.error "Error code #{exit_code}"
    end
  end
end