✨ Replace dotenv with custom implementation#426
Merged
Conversation
samarsault
pushed a commit
that referenced
this pull request
Mar 3, 2023
Bumps [eslint-plugin-promise](https://github.com/xjamundx/eslint-plugin-promise) from 5.1.0 to 5.1.1. - [Release notes](https://github.com/xjamundx/eslint-plugin-promise/releases) - [Changelog](https://github.com/xjamundx/eslint-plugin-promise/blob/development/CHANGELOG.md) - [Commits](https://github.com/xjamundx/eslint-plugin-promise/commits) --- updated-dependencies: - dependency-name: eslint-plugin-promise dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What is this?
As requested by #410, it's nice to be able to interpolate environment variables within other environment variables. As suggested in the issue, I started with the
dotenv-expandpackage and added it as a dependency. Upon a quick review of its internals, I noticed that not only was it small and still did more than we needed, but it was also a bit inefficient with several loops and unnecessary regular expression creations within those loops.After implementing a more succinct variable expansion helper, I was checking against dotenv-rails, which is what we always intended to mimic. I then noticed there were several other differences with the dotenv package we were using related to variable interpolation, escaping, file parsing, and other features.
The dotenv package we were using was pretty small, so it was fairly straightforward to copy it over and trim away everything we didn't need. For example, we always want to set
process.envwhen it isn't already, while dotenv libraries are split up to allow parsing without settingprocess.env. After cutting away the fat, changes were made to align with dotenv-rails, including variable substitution (the original goal of this PR).Most changes were ported over from dotenv-rails directly, such as the regular expression used to parse the file and the logic behind expanding, unescaping, and interpolating values.