Class: Wordmove::Hook::Remote
- Inherits:
-
Object
- Object
- Wordmove::Hook::Remote
- Defined in:
- lib/wordmove/hook.rb
Class Method Summary collapse
- .logger ⇒ Object
-
.run(command_hash, options, simulate = false) ⇒ Object
rubocop:disable Style/OptionalBooleanParameter.
Class Method Details
.logger ⇒ Object
102 103 104 |
# File 'lib/wordmove/hook.rb', line 102 def self.logger Wordmove::Hook.logger end |
.run(command_hash, options, simulate = false) ⇒ Object
rubocop:disable Style/OptionalBooleanParameter
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/wordmove/hook.rb', line 106 def self.run(command_hash, , simulate = false) # rubocop:disable Style/OptionalBooleanParameter = [:ssh] wordpress_path = [:wordpress_path] copier = Photocopier::SSH.new().tap { |c| c.logger = logger } logger.task_step false, "Exec command: #{command_hash[:command]}" return true if simulate stdout, stderr, exit_code = copier.exec!("cd #{wordpress_path} && #{command_hash[: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}" raise Wordmove::RemoteHookException unless command_hash[:raise].eql? false end end |