Sha256: 2876b424a8848ab32a55f406d5118ec90c8884b563e9f7646822c3d5b3d95516

Contents?: true

Size: 831 Bytes

Versions: 19

Compression:

Stored size: 831 Bytes

Contents

# frozen_string_literal: true

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

module Bolt
  module Transport
    class Local
      class Shell
        def execute(*command, options)
          if options[:env]
            env = options[:env].each_with_object({}) { |(k, v), h| h["PT_#{k}"] = v.to_s }
            command = [env] + command
          end

          if options[:stdin]
            stdout, stderr, rc = Open3.capture3(*command, stdin_data: options[:stdin])
          else
            stdout, stderr, rc = Open3.capture3(*command)
          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.to_i
          result_output
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
bolt-0.21.8 lib/bolt/transport/local/shell.rb
bolt-0.21.7 lib/bolt/transport/local/shell.rb
bolt-0.21.6 lib/bolt/transport/local/shell.rb
bolt-0.21.5 lib/bolt/transport/local/shell.rb
bolt-0.21.4 lib/bolt/transport/local/shell.rb
bolt-0.21.3 lib/bolt/transport/local/shell.rb
bolt-0.21.2 lib/bolt/transport/local/shell.rb
bolt-0.21.1 lib/bolt/transport/local/shell.rb
bolt-0.21.0 lib/bolt/transport/local/shell.rb
bolt-0.20.7 lib/bolt/transport/local/shell.rb
bolt-0.20.6 lib/bolt/transport/local/shell.rb
bolt-0.20.5 lib/bolt/transport/local/shell.rb
bolt-0.20.3 lib/bolt/transport/local/shell.rb
bolt-0.20.2 lib/bolt/transport/local/shell.rb
bolt-0.20.0 lib/bolt/transport/local/shell.rb
bolt-0.19.1 lib/bolt/transport/local/shell.rb
bolt-0.19.0 lib/bolt/transport/local/shell.rb
bolt-0.18.2 lib/bolt/transport/local/shell.rb
bolt-0.18.1 lib/bolt/transport/local/shell.rb