Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the loader "Lucky Aware" #4

Open
jwoertink opened this issue Mar 24, 2021 · 0 comments
Open

Make the loader "Lucky Aware" #4

jwoertink opened this issue Mar 24, 2021 · 0 comments

Comments

@jwoertink
Copy link
Member

Right now if you want to load a different env file based on what Lucky::Env.name is, then you have to use a ternary or something:

require "lucky_env"

env_file = Lucky::Env.test? ? ".env.test" : ".env"
LuckyEnv.load(env_file)

This is fine, but it would be better if you didn't have to consider that. Sort of playing off #1, we could even move this code in. Then maybe your spec_helper.cr does something like:

# spec/spec_helper.cr
ENV["LUCK_ENV"] = "test"
require "spec"

# ...

Then in your app, you'd have:

# src/shards.cr
require "lucky_env"
LuckyEnv.load!

This method would know that if ENV["LUCKY_ENV"] was set to "test", then we should auto-load .env.test. The Rails env has something similar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant