Sha256: 88f6a7e2719b62efe44a9f13f0daeab998d29b1cfae1110ebb6acf3ed8e22214

Contents?: true

Size: 774 Bytes

Versions: 4

Compression:

Stored size: 774 Bytes

Contents

# frozen_string_literal: true

require 'open3'
require 'bolt/node/output'

module Bolt
  module Transport
    class Local
      class Shell
        def execute(*command, options)
          command = [options[:env]] + command if options[:env]

          if options[:stdin]
            stdout, stderr, rc = Open3.capture3(*command, stdin_data: options[:stdin], chdir: options[:dir])
          else
            stdout, stderr, rc = Open3.capture3(*command, chdir: options[:dir])
          end

          result_output = Bolt::Node::Output.new
          result_output.stdout << stdout unless stdout.nil?
          result_output.stderr << stderr unless stderr.nil?
          result_output.exit_code = rc.exitstatus
          result_output
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bolt-1.12.0 lib/bolt/transport/local/shell.rb
bolt-1.11.0 lib/bolt/transport/local/shell.rb
bolt-1.10.0 lib/bolt/transport/local/shell.rb
bolt-1.9.0 lib/bolt/transport/local/shell.rb