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

Cascade -e files when combined with -c #44

Merged
merged 3 commits into from
Sep 13, 2020
Merged

Cascade -e files when combined with -c #44

merged 3 commits into from
Sep 13, 2020

Conversation

davecardwell
Copy link
Contributor

@davecardwell davecardwell commented Sep 10, 2020

This change makes it so that when combining the -c and -e flags it is the extra files that will get the .local and environment specific versions. This is a change from the current behavior which cascades to .env.local, .env, extra so this may necessitate a major version bump, but I think is a more consistent behavior.

To demonstrate…

flags original new
[ '.env' ] [ '.env' ]
-c [ '.env.local', '.env' ] [ '.env.local', '.env' ]
-c foo [ '.env.foo.local', '.env.foo', '.env.local', '.env' ] [ '.env.foo.local', '.env.foo', '.env.local', '.env' ]
-e bar [ 'bar' ] [ 'bar' ]
-c -e bar [ '.env.local', '.env', 'bar' ] [ 'bar.local', 'bar' ]
-c foo -e bar [ '.env.foo.local', '.env.foo', '.env.local', '.env', 'bar' ] [ 'bar.foo.local', 'bar.foo', 'bar.local', 'bar' ]

I also added a --debug flag to make it easier to see what files dotenv-cli will process.

Fixes #43

When using `-e` and `-c` together we should load the .<env> and .local
versions of the files specified by `-e`.

Note that this is a change from the behavior introduced in
ba7c7ba (v3.2.0) when combining
`-e extra` with `-c` would result in processing:
[ '.env.local', '.env', 'extra' ]

It will now process:
[ 'extra.local', 'extra' ]
@davecardwell davecardwell changed the title Cascade -e files when combined with -c (fixes #43) Cascade -e files when combined with -c Sep 10, 2020
Copy link
Owner

@entropitor entropitor left a comment

Choose a reason for hiding this comment

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

Your table in the PR helps a lot, I guess it would be nice to have unit tests for these but well, it is what it is.

WDYT about the suggestion?

cli.js Outdated Show resolved Hide resolved
Co-authored-by: Jens Claes <jensclaes33@gmail.com>

Fix variable name
@entropitor entropitor merged commit 3458d5e into entropitor:master Sep 13, 2020
@entropitor
Copy link
Owner

Released as v4.0.0

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

Successfully merging this pull request may close these issues.

.env.<environment> with the -e flag
2 participants