Sha256: 54fccdfd4855f81e5a590fd1e81ca432ce9dad69887c99321d8049a94c9ae17e

Contents?: true

Size: 631 Bytes

Versions: 1

Compression:

Stored size: 631 Bytes

Contents

# frozen_string_literal: true

module CobraCommander
  module Executor
    module RunScript
      def run_script(tty, script, path)
        result = tty.run!(script, chdir: path, err: :out)

        return [:error, result.out] if result.failed?

        [:success, result.out]
      end

      def run_many(collection, &block)
        collection.lazy.map(&block)
                  .reduce do |(_, prev_output), (result, output)|
          new_output = [prev_output&.strip, output&.strip].join("\n")
          return [:error, new_output] if result == :error

          [:success, new_output]
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cobra_commander-1.1.0 lib/cobra_commander/executor/run_script.rb