rajivharris / Set-PsEnv

PowerShell DotEnv Loader
MIT License
47 stars 12 forks source link

Using Set-PsEnv Programmatically #14

Open khill-fbmc opened 1 year ago

khill-fbmc commented 1 year ago

I ran into the issue when using this in a script.

On first run of the script, the .env is read and $env is populated. Upon re-run, it fails to load because it thinks we already have (same dir)

https://github.com/rajivharris/Set-PsEnv/blob/1be3a967e18827d62e0815040a5f12a4706ae94a/Set-PsEnv.psm1#L35-L40

khill-fbmc commented 1 year ago

My workaround was to just clear $Global:PreviousDir = "" before calling Set-PsEnv

rrmistry commented 8 months ago

I ran into the same issue and found the same workaround.

It would be ideal to have a -Force flag so that the module loads .env file regardless of whether it is the same folder or not.

CC: @rajivharris Thank you for creating this package. Much appreciated!