Sha256: 422f26d5d22c436835c30fbdf166fda283696176a11bf79b2fd743651c307855

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

require "bundler"

class Lono::Blueprint
  module Root
    # Switch the lono root
    # TODO: account multimode or only have multimode?
    # TODO: switch to gem path
    def set_blueprint_root(blueprint)
      # puts "blueprint #{blueprint}"
      # puts caller[0..2]

      blueprint_root = find_blueprint_root(blueprint)
      if blueprint_root
        Lono.blueprint_root = blueprint_root
      else
        puts "ERROR: Unable to find the blueprint #{blueprint}.  " \
            "Are you sure it's in your Gemfile or in the blueprints folder "\
            "with the correct blueprint_name in .lono/config.yml?".color(:red)
        List.available
        exit 1
      end
    end

    def find_blueprint_root(blueprint)
      require_bundle_gems # ensures that gem will be found so we can switch to it

      Find.find(blueprint) # blueprint_root
    end

    def bundler_groups
      [:default, Lono.env.to_sym]
    end

    def require_bundle_gems
      # NOTE: Dont think ENV['BUNDLE_GEMFILE'] is quite working right.  We still need
      # to be in the project directory.  Leaving logic in here for when it gets fix.
      if ENV['BUNDLE_GEMFILE'] || File.exist?("Gemfile")
        require "bundler/setup"
        Bundler.require(*bundler_groups)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lono-5.1.1 lib/lono/blueprint/root.rb
lono-5.1.0 lib/lono/blueprint/root.rb
lono-5.0.1 lib/lono/blueprint/root.rb