Method: Kennel::Tasks.load_environment

Defined in:
lib/kennel/tasks.rb

.load_environmentObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/kennel/tasks.rb', line 16

def load_environment
  @load_environment ||= begin
    require "kennel"
    gem "dotenv"
    require "dotenv"
    source = ".env"

    # warn when users have things like DATADOG_TOKEN already set and it will not be loaded from .env
    unless ENV["KENNEL_SILENCE_UPDATED_ENV"]
      updated = Dotenv.parse(source).select { |k, v| ENV[k] && ENV[k] != v }
      warn "Environment variables #{updated.keys.join(", ")} need to be unset to be sourced from #{source}" if updated.any?
    end

    Dotenv.load(source)
    true
  end
end