Sha256: 41d9992b475e2c57a730623e60fc9d1f9ea43aeaba83df9b5569f559331097ca

Contents?: true

Size: 848 Bytes

Versions: 4

Compression:

Stored size: 848 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.unshift(options[:interpreter]) if options[:interpreter]
          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.15.0 lib/bolt/transport/local/shell.rb
bolt-1.14.0 lib/bolt/transport/local/shell.rb
bolt-1.13.1 lib/bolt/transport/local/shell.rb
bolt-1.13.0 lib/bolt/transport/local/shell.rb