Class: Bonchi::Setup
- Inherits:
-
Object
- Object
- Bonchi::Setup
- Defined in:
- lib/bonchi/setup.rb
Instance Method Summary collapse
-
#initialize(worktree: nil) ⇒ Setup
constructor
A new instance of Setup.
- #run(args = []) ⇒ Object
Constructor Details
#initialize(worktree: nil) ⇒ Setup
Returns a new instance of Setup.
6 7 8 9 |
# File 'lib/bonchi/setup.rb', line 6 def initialize(worktree: nil) @worktree = worktree || Dir.pwd @main_worktree = Git.main_worktree end |
Instance Method Details
#run(args = []) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/bonchi/setup.rb', line 11 def run(args = []) if @worktree == @main_worktree abort "Error: already in the main worktree" end config = Config.from_main_worktree abort "Error: .worktree.yml not found in main worktree" unless config ENV["MAIN_WORKTREE"] = @main_worktree ENV["WORKTREE"] = @worktree puts "Setting up worktree from: #{@main_worktree}" allocate_ports(config.ports) if config.ports.any? copy_files(config.copy) run_pre_setup(config.pre_setup) exec_setup(config.setup, args) end |