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

Improvements for usage with .envrc files #6

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

kjellski
Copy link

feat: allow reading of bash .envrc files
feat: Write-Output when no file was found
feat: don't skip if current file was already applied, could've been changed

feat: Write-Output when no file was found
feat: don't skip if current file was already applied, could've been changed
@kjellski
Copy link
Author

Heyy @rajivharris - if you're cool with these changes, I would extend the script with the ability to search for the other filetypes as well. It might be very usefull to let it look for .envrc as well as .env and possibly others? Suggestions are welcome.

@kjellski
Copy link
Author

Disregard my last comment, I've added it anyways - it now behaves a bit like direnv 👍

@rajivharris
Copy link
Owner

Thanks @kjellski for submitting the feature request. Appreciate your effort for also submitting a PR for that. Will go through your changes over my free time and will get back to you.

@rajivharris
Copy link
Owner

feat: allow reading of bash .envrc files

It would be great allowing different file formats. The file format of .env and .envrc files are different. Set-PsEnv .env file is opiniated and allows you to prefix or suffix an existing env variable. So it will fail when it tries to parse the .envrc file. Also the goal of Set-PsEnv is simple, export your env variables dynamically based on the directory. It does not try to execute any code/function on load (which is possible in .envrc) as it is a security issue in some enterprise orgs.

feat: Write-Output when no file was found

This is already supported but you have run the module in verbose mode. This is to avoid unnecessary cluttering of the terminal as it is preferred by some users.

feat: don't skip if current file was already applied, could've been changed

This would be a good feature to have. But I believe it should be a conditional reload ( PowerShell calls prompt function every time a command is executed). There are few ways to do it, two things occurred to me was

  1. Computing hash
    Compute a hash based on the content of the file. If the hash changes reload the file. But if the file is big, it would take time.

  2. Check file timestamp
    Store the timestamp of the .env file on load and reload if it is changed.

I think 2nd option is simple and straight forward.

Please let me know you thoughts.

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.

2 participants