Skip to content

✨ Replace dotenv with custom implementation#426

Merged
wwilsman merged 2 commits intomasterfrom
ww/dotenv-substitution
Jul 19, 2021
Merged

✨ Replace dotenv with custom implementation#426
wwilsman merged 2 commits intomasterfrom
ww/dotenv-substitution

Conversation

@wwilsman
Copy link
Copy Markdown
Contributor

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-expand package 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.env when it isn't already, while dotenv libraries are split up to allow parsing without setting process.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.

@wwilsman wwilsman added the ✨ enhancement New feature or request label Jul 16, 2021
@wwilsman wwilsman requested a review from Robdel12 July 16, 2021 21:24
@wwilsman wwilsman enabled auto-merge (squash) July 16, 2021 21:31
Copy link
Copy Markdown
Contributor

@Robdel12 Robdel12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏁 Verry nice

@wwilsman wwilsman merged commit 6b98230 into master Jul 19, 2021
@wwilsman wwilsman deleted the ww/dotenv-substitution branch July 19, 2021 15:25
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants