Module: CobraCommander::Executor::RunScript

Included in:
Command, Script
Defined in:
lib/cobra_commander/executor/run_script.rb

Instance Method Summary collapse

Instance Method Details

#run_many(collection, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/cobra_commander/executor/run_script.rb', line 14

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

#run_script(tty, script, path) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/cobra_commander/executor/run_script.rb', line 6

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