Class: Kettle::Family::CommandRunner
- Inherits:
-
Object
- Object
- Kettle::Family::CommandRunner
- Defined in:
- lib/kettle/family/command_runner.rb
Defined Under Namespace
Classes: OtpCoordinator
Instance Method Summary collapse
- #call(member:, phase:, command:, env: {}, interactive: false) ⇒ Object
-
#initialize(execute: false, accept: true, gem_signing_password: nil, otp_coordinator: nil) ⇒ CommandRunner
constructor
A new instance of CommandRunner.
Constructor Details
#initialize(execute: false, accept: true, gem_signing_password: nil, otp_coordinator: nil) ⇒ CommandRunner
Returns a new instance of CommandRunner.
107 108 109 110 111 112 |
# File 'lib/kettle/family/command_runner.rb', line 107 def initialize(execute: false, accept: true, gem_signing_password: nil, otp_coordinator: nil) @execute = execute @accept = accept @gem_signing_password = gem_signing_password @otp_coordinator = otp_coordinator end |
Instance Method Details
#call(member:, phase:, command:, env: {}, interactive: false) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/kettle/family/command_runner.rb', line 114 def call(member:, phase:, command:, env: {}, interactive: false) argv = command_argv(member: member, command: command, env: env) process_env = process_env(member: member, env: env) = return skipped_result(member: member, phase: phase, argv: argv) unless execute started = Process.clock_gettime(Process::CLOCK_MONOTONIC) stdout, stderr, status = if interactive run_interactive(env: process_env, argv: argv, chdir: member.root, member_name: member.name, process_options: ) else Open3.capture3(process_env, *argv, chdir: member.root, **) end stdout = normalize_output(stdout) stderr = normalize_output(stderr) elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - started CommandResult.new( member_name: member.name, phase: phase, command: argv, workdir: member.root, status: status.exitstatus, success: status.success?, stdout: stdout, stderr: stderr, elapsed_seconds: elapsed.round(3), skipped: false, reason: status.success? ? nil : "command failed" ) end |