Sha256: 77ab99d345abdeff1d6432828ca25c0ff93c067318b70f601a736dee081d9364
Contents?: true
Size: 855 Bytes
Versions: 9
Compression:
Stored size: 855 Bytes
Contents
# frozen_string_literal: true module Jive class Shell COMMAND_MAP = { cd: "/usr/bin/cd", echo: "/usr/bin/echo", git: "/usr/bin/git", mkdir: "/usr/bin/mkdir" }.freeze def run_each(tasks) tasks.each do |task| break unless execute(task) end end def execute(command, env: {}) system(env, expand(command)) end def after_run(tasks) finalizer_fd = 42 pipe = IO.new(finalizer_fd) pipe.puts(tasks.map { |x| x.join(":") }.join("\n")) rescue Errno::EBADF => e puts e exit 1 end def expand(command) Array(command) .flatten .map { |x| COMMAND_MAP.fetch(x, x).to_s } .join(" ") end def run_safely yield rescue StandardError => e puts e after_run([%w[noop noop]]) end end end
Version data entries
9 entries across 9 versions & 1 rubygems