Sha256: c041b55315d9af0e9c94aaba44f7e183d590c37081458a0fb2d3e0cf4bf2e3f0
Contents?: true
Size: 1.22 KB
Versions: 47
Compression:
Stored size: 1.22 KB
Contents
require 'dotenv' class Jets::Dotenv def self.load!(remote=false) new(remote).load! end def initialize(remote=false) @remote = ENV['JETS_ENV_REMOTE'] || remote end def load! return if on_aws? # this prevents ssm calls if used in dotenv files vars = ::Dotenv.load(*dotenv_files) Ssm.new(vars).interpolate! end def on_aws? !!ENV['_HANDLER'] # https://docs.aws.amazon.com/lambda/latest/dg/lambda-environment-variables.html end # dotenv files with the following precedence: # # - .env.development.jets_env_extra (highest) # - .env.development.remote (2nd highest) # - .env.development.local # - .env.development # - .env.local - This file is loaded for all environments _except_ `test`. # - .env - The original (lowest) # def dotenv_files files = [ root.join(".env"), (root.join(".env.local") unless Jets.env.test?), root.join(".env.#{Jets.env}"), root.join(".env.#{Jets.env}.local"), ] files << root.join(".env.#{Jets.env}.remote") if @remote if ENV["JETS_ENV_EXTRA"] files << root.join(".env.#{Jets.env}.#{ENV["JETS_ENV_EXTRA"]}") end files.compact end def root Jets.root || Pathname.new(ENV["JETS_ROOT"] || Dir.pwd) end end
Version data entries
47 entries across 47 versions & 2 rubygems