summaryrefslogtreecommitdiff
path: root/lib/jive/project.rb
blob: b3aafe5ff43ea6a6ca77be5f68e6632241af304f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

module Jive
  class Project
    attr_reader :path

    def initialize(path)
      @path = path
    end

    def bootstrap(shell)
      tasks = []
      tasks << [:asdf, "install"]
      tasks << [:bundle, "install"] if bundler?
      tasks << [:yarn, "install"] if yarn?

      shell.run_safely do
        shell.run_each(tasks)
      end
    end

    private

    def bundler?
      path.join("Gemfile").exist? ||
        path.glob("*.gemspec").any?
    end

    def yarn?
      path.join("yarn.lock").exist?
    end
  end
end