Sha256: f0890cc7e3804ea44dceca6786c86d79417c62a06167a8200659a491e771161a

Contents?: true

Size: 617 Bytes

Versions: 2

Compression:

Stored size: 617 Bytes

Contents

# frozen_string_literal: true

require "open3"

module Jekyll
  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

2 entries across 2 versions & 2 rubygems

Version Path
jekyll-4.2.1 lib/jekyll/utils/exec.rb
ngage-0.0.0 lib/ngage/jekyll/utils/exec.rb