Module: KKGit::RakeRunner

Defined in:
lib/kk/git/rake_runner.rb

Overview

Run root Rakefile in-process (avoids subprocess rake and duplicate gem loads).

Class Method Summary collapse

Class Method Details

.run!(root:, argv: []) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/kk/git/rake_runner.rb', line 10

def run!(root:, argv: [])
  root = File.expand_path(root)
  Dir.chdir(root)

  lib = File.join(root, 'lib')
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

  require 'rake'
  load File.join(root, 'Rakefile')

  tasks = argv.empty? ? ['push'] : argv.dup
  failed = Rake.application.run(tasks)
  exit(failed ? 1 : 0)
end