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

Configurable env path from ngxEnv options #42

Merged
merged 2 commits into from
May 28, 2023
Merged

Configurable env path from ngxEnv options #42

merged 2 commits into from
May 28, 2023

Conversation

otonielguajardo
Copy link
Contributor

@otonielguajardo otonielguajardo commented May 27, 2023

dotenv supports specifying the path of the .env file, this PR tries to acomplish the same.

It would be awesome for proyects with structures like this:
Screenshot 2023-05-27 at 1 46 21 a m

closes #43

@chihab
Copy link
Owner

chihab commented May 28, 2023

Hey, very good idea.

I've created an issue to discuss the idea. Let me know what you think please. #43

@chihab
Copy link
Owner

chihab commented May 28, 2023

could you add the option to the ngx-env.json file?

"path": {
    "type": "string",
    "description": "@ngx-env/builder path to .env file",
    "default": ".env"
}

@@ -13,9 +13,9 @@ function escapeStringRegexp(str: string) {
return str.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
}

function getClientEnvironment(prefix: RegExp) {
function getClientEnvironment(prefix: RegExp, envPath: string = ".env") {
Copy link
Owner

Choose a reason for hiding this comment

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

by adding a default value to ngxEnv builder options (previous comment), the default value here is not needed

remove envPath default value from getClientEnvironment()
@otonielguajardo
Copy link
Contributor Author

could you add the option to the ngx-env.json file?

"path": {
    "type": "string",
    "description": "@ngx-env/builder path to .env file",
    "default": ".env"
}

Sure thing! I've updated the PR

@chihab chihab merged commit 25685ae into chihab:main May 28, 2023
1 check passed
@chihab
Copy link
Owner

chihab commented May 29, 2023

Thank you @otonielguajardo!

@otonielguajardo otonielguajardo deleted the configurable-env-path branch May 31, 2023 21:58
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.

Specify path to .env file(s)
2 participants