Class: Ask::Ruby::Harness::Tools::RunCommand

Inherits:
Ask::Ruby::Harness::Tool show all
Defined in:
lib/ask/ruby/harness/tools/run_command.rb

Instance Method Summary collapse

Methods inherited from Ask::Ruby::Harness::Tool

#app_root, #call, session_id, session_id=

Instance Method Details

#execute(command:) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/ask/ruby/harness/tools/run_command.rb', line 11

def execute(command:)
  check_result = check_command_allowed(command)
  return check_result if check_result

  output = `cd #{app_root} && #{command} 2>&1`
  Ask::Result.ok(
    data: { output: output, exit_status: $?.exitstatus },
    metadata: { exit_status: $?.exitstatus }
  )
end