vscode-restclient icon indicating copy to clipboard operation
vscode-restclient copied to clipboard

[Feature] add support for vscode env in dotenv

Open nicksmider opened this issue 2 years ago • 1 comments

This PR allows the users to create .env files for each environment that exists within their vscode settings.

Screenshot 2023-05-01 at 2 51 24 PM

Behavior: When walking back up the path, when either .env or .env.{vscode-env} is found, stop and prefer .env.{vscode-env}.

Use case: I want to specify an auth token in gitignored env files because the repo's settings.json is checked into source control already so we cannot place them in there safely.

Closes https://github.com/Huachao/vscode-restclient/issues/740

nicksmider avatar May 01 '23 18:05 nicksmider

Will this read the .env file in the root of code that's currently open?

shaunakv1 avatar Feb 10 '24 04:02 shaunakv1

@nicksmider merged, thanks

Huachao avatar Jul 29 '24 04:07 Huachao

Wondering, why there is not a dotenv module used? It does the same and pretty much all frameworks using it

FDiskas avatar Jul 29 '24 09:07 FDiskas

@FDiskas the dotenv is already used by the project

Huachao avatar Jul 30 '24 01:07 Huachao

Based on the use case outlined by @nicksmider I think a better approach would be to first load the .env file and then load values from .env.local as overrides. From the description it sounds like users will need to copy all values from the .env file and now there are two things to maintain.

sayedihashimi avatar Jul 30 '24 01:07 sayedihashimi

@FDiskas the dotenv is already used by the project

But why then env file loading is done manually? https://www.npmjs.com/package/dotenv#should-i-have-multiple-env-files

FDiskas avatar Jul 30 '24 16:07 FDiskas