Skip to content

Add support for default expansion of environment variables by bumping dotenv-expand dependency #12824

Open

Description

@hovsater

Is your proposal related to a problem?

Sometimes you may depend on environment variables in some way and may want to provide a default value in case one is not set. For instance, we have an API gateway that we need to configure locally and it's based on the current URL. In .env we set it up as follows:

REACT_APP_API_GATEWAY_BASE_URL=localhost:${PORT}

This works as long as PORT is set. create-react-app defaults to port 3000 in case it's not set. Ideally, we'd like to express that in our .env file using default expansion:

REACT_APP_API_GATEWAY_BASE_URL=localhost:${PORT:-300}

Unfortunately, this doesn't work as the current version of dotenv-expand does not support it. Default expansion was introduced in 6.0.0.

Describe the solution you'd like

Consider bumping dotenv-expand (and by extension, dotenv) to at least version 6.0.1 to add support for default expansion (e.g., ${VAR:-DEFAULT}. This is helpful when you want to provide a default value in case an environment variable isn't set.

Describe alternatives you've considered

None.

Additional context

None.

Activity

  1. opterion commented on Jun 2, 2023

    @opterion

    Hi) Any updates about this issue? Would it be added in the nearest future?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions