Sha256: 85586deaef260afd08526dfdcfa9d5ed52df81e480685fb7da1b51acc59dd9fa

Contents?: true

Size: 782 Bytes

Versions: 4

Compression:

Stored size: 782 Bytes

Contents

# frozen_string_literal: true

require "tty-command"

module CobraCommander
  module Executor
    # Execute a command on a single component
    class ComponentExec
      def initialize(component)
        @component = component
      end

      def run(command, output: $stdout, **cmd_options)
        tty = TTY::Command.new(pty: true, printer: :quiet, output: output)
        isolate_bundle do
          @component.root_paths.all? do |path|
            tty.run!(command, chdir: path, **cmd_options).success?
          end
        end
      end

    private

      def isolate_bundle(&block)
        if Bundler.respond_to?(:with_unbundled_env)
          Bundler.with_unbundled_env(&block)
        else
          Bundler.with_clean_env(&block)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cobra_commander-0.11.0 lib/cobra_commander/executor/component_exec.rb
cobra_commander-0.10.0 lib/cobra_commander/executor/component_exec.rb
cobra_commander-0.9.2 lib/cobra_commander/executor/component_exec.rb
cobra_commander-0.9.1 lib/cobra_commander/executor/component_exec.rb