Sha256: 62bf47a1215547505fe9435c8f9015965bfea690db3af8a043035728bd2ff606
Contents?: true
Size: 732 Bytes
Versions: 4
Compression:
Stored size: 732 Bytes
Contents
# frozen_string_literal: true module CobraCommander # Execute commands on all components of a ComponentTree class Executor def initialize(tree) @tree = tree end def exec(command, printer = $stdout) @tree.flatten.each do |component| printer.puts "===> #{component.name} (#{component.path})" output, = run_in_component(component, command) printer.puts output end end private def run_in_component(component, command) Dir.chdir(component.path) do Open3.capture2e(env_vars(component), command) end end def env_vars(component) { "CURRENT_COMPONENT" => component.name, "CURRENT_COMPONENT_PATH" => component.path } end end end
Version data entries
4 entries across 4 versions & 1 rubygems