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

Using Set-PsEnv Programmatically #14

Open
khill-fbmc opened this issue Jun 16, 2023 · 2 comments
Open

Using Set-PsEnv Programmatically #14

khill-fbmc opened this issue Jun 16, 2023 · 2 comments

Comments

@khill-fbmc
Copy link

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)

Set-PsEnv/Set-PsEnv.psm1

Lines 35 to 40 in 1be3a96

if($Global:PreviousDir -eq (Get-Location).Path){
Write-Verbose "Set-PsEnv:Skipping same dir"
return
} else {
$Global:PreviousDir = (Get-Location).Path
}

@khill-fbmc
Copy link
Author

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

@rrmistry
Copy link

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!

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

No branches or pull requests

2 participants