fix: better defined & documented .env and ENV_VAR support #14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This closes #13.
Briefly: from the beginning I had defined a
.env
inside the repo which gotsource
d along with any other supplied.env
file at generation time. This was incredibly convenient, especially when building and testing locally. However, I never really liked that for theSITE_*
variables, which were more or less required for the Full Opinionated Experience™, there was the potential to just have the mostly-useless ones hanging out.And more frustratingly, because the
.env
was always sourced it would override anything defined at runtime e.g.SITE_URL=http://domain.tld bic .
This work fixes all that up by leaving an effectively-empty repo
.env
and having any defaults defined${VAR:-default}
-style in bic itself and simply printing a warning message if the importantSITE_*
aren't defined. Further, if someone wanted to define a variable in their.env
and have it be overridable at runtime this can be done withVAR="${VAR:-default}"
My motivation to keep the repo
.env
around is maybe I'll want it in the future e.g. some build metadata. Alternatively, I could use the aforementioned syntax to define the optional config (BUILD_DIR
,DATE_FORMAT
,SALT
, andTIMEZONE
) but as it stands I'd rather leave those in the source code.