Sha256: caa7f45d29012e89a6c25b0f51fd7dccd116e71e61db090ce8e13f7c3edc62b7

Contents?: true

Size: 595 Bytes

Versions: 37

Compression:

Stored size: 595 Bytes

Contents

# frozen_string_literal: true

require "open3"

module Bridgetown
  module Utils
    module Exec
      extend self

      # Runs a program in a sub-shell.
      #
      # *args - a list of strings containing the program name and arguments
      #
      # Returns a Process::Status and a String of output in an array in
      # that order.
      def run(*args)
        stdin, stdout, stderr, process = Open3.popen3(*args)
        out = stdout.read.strip
        err = stderr.read.strip

        [stdin, stdout, stderr].each(&:close)
        [process.value, out + err]
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
bridgetown-core-0.19.3 lib/bridgetown-core/utils/exec.rb
bridgetown-core-0.19.2 lib/bridgetown-core/utils/exec.rb
bridgetown-core-0.19.1 lib/bridgetown-core/utils/exec.rb
bridgetown-core-0.19.0 lib/bridgetown-core/utils/exec.rb
bridgetown-core-0.18.6 lib/bridgetown-core/utils/exec.rb
bridgetown-core-0.18.5 lib/bridgetown-core/utils/exec.rb
bridgetown-core-0.18.4 lib/bridgetown-core/utils/exec.rb
bridgetown-core-0.18.3 lib/bridgetown-core/utils/exec.rb
bridgetown-core-0.18.2 lib/bridgetown-core/utils/exec.rb
bridgetown-core-0.18.1 lib/bridgetown-core/utils/exec.rb
bridgetown-core-0.18.0 lib/bridgetown-core/utils/exec.rb
bridgetown-core-0.17.1 lib/bridgetown-core/utils/exec.rb
bridgetown-core-0.17.0 lib/bridgetown-core/utils/exec.rb
bridgetown-core-0.16.0 lib/bridgetown-core/utils/exec.rb
bridgetown-core-0.16.0.beta2 lib/bridgetown-core/utils/exec.rb
bridgetown-core-0.16.0.beta1 lib/bridgetown-core/utils/exec.rb
bridgetown-core-0.15.0 lib/bridgetown-core/utils/exec.rb
bridgetown-core-0.15.0.beta4 lib/bridgetown-core/utils/exec.rb
bridgetown-core-0.15.0.beta3 lib/bridgetown-core/utils/exec.rb
bridgetown-core-0.15.0.beta2 lib/bridgetown-core/utils/exec.rb