2018-09-03 15:14:05 +02:00
|
|
|
|
# Ensure that the environment variables defined in the reference env vars file
|
|
|
|
|
# are present in the execution environment.
|
|
|
|
|
#
|
|
|
|
|
# This protects against an out-to-date environment leading to runtime errors.
|
|
|
|
|
|
|
|
|
|
if ENV['RAILS_ENV'] != 'test' && File.basename($0) != 'rake'
|
|
|
|
|
reference_env_file = File.join('config', 'env.example')
|
2018-12-24 17:53:16 +01:00
|
|
|
|
Dotenv::Environment.new(Rails.root.join(reference_env_file)).each do |key, _value|
|
2018-09-03 15:14:05 +02:00
|
|
|
|
if !ENV.key?(key.to_s)
|
|
|
|
|
raise "Configuration error: `#{key}` is not present in the process’ environment variables (declared in `#{reference_env_file}`)"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|