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

Allow specifying which config and .env files to load by another environment variable than NODE_ENV #1004

Closed
sgronblo opened this issue Nov 29, 2021 · 1 comment

Comments

@sgronblo
Copy link

I brought this up on the Discord channel as well but the discussion got lost there so I thought it was better to move it to an actual GH issue.

The NODE_ENV variable seems to never have been officially described how it should be used. Instead it seems to have been used arbitrarily by the npm community to sometimes change the runtime behavior of packages. It seems package maintainers are checking for at least development/production/test and have that affect the behavior.

By Foal only allowing NODE_ENV as the single way to specify which configuration to use, it takes away control from users who cannot both control which config files to use at the same time as controlling runtime behavior of npm packages.

As a theoretical example we might have:

  1. Two production-like environments staging and production
  2. Some npm package that does things one way for NODE_ENV===production and another way when NODE_ENV!==production

In this case it would be impossible or at best very difficult to specify that we want the NODE_ENV===production from the npm package but want to read config from the staging.json and .env.staging files.

It seems NODE_ENV is only referenced a few times in FoalTS's code base so it seems it shouldn't be too hard to use another environment variable such as FOAL_ENV or RUN_ENV which could be set to override NODE_ENV when looking up env values or config values.

@LoicPoullain LoicPoullain added this to Backlog in Issue tracking via automation Dec 5, 2021
@LoicPoullain LoicPoullain moved this from Backlog to To Do in Issue tracking Dec 5, 2021
@LoicPoullain LoicPoullain moved this from To Do to Work In Progress in Issue tracking Dec 8, 2021
@LoicPoullain
Copy link
Member

Thank you for raising this point @sgronblo and proposing this solution. Feature has been added to v2.7.

Issue tracking automation moved this from Work In Progress to Done / Closed This Release Dec 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Issue tracking
  
Done / Closed This Release
Development

No branches or pull requests

2 participants