Skip to content

Commit

Permalink
feat: added on-remove event handlers to unload environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Taylan Gökkaya committed Jun 18, 2022
1 parent c919e15 commit a931c89
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion module/Dotenv.psd1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@{
RootModule = "Dotenv.psm1"
ModuleVersion = "0.6.5"
ModuleVersion = "0.7.0"
Author = "Taylan Gökkaya<[email protected]>"
CompatiblePSEditions = @("Core")
GUID = '3bb5d7a3-985c-4d74-a329-8dddb075e322'
Expand Down
9 changes: 9 additions & 0 deletions module/Dotenv.psm1
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
New-Variable -Option ReadOnly Dotenv ([Dotenv.Daemon]::new())

$ExecutionContext.SessionState.Module.OnRemove += {
if($global:Dotenv.Enabled) {
Write-Host "dotenv: unloading..."
$global:Dotenv.Disable()
remove-item -force -ea silentlyContinue variable:/Dotenv
}
}

[string]$lastdir = $pwd.providerpath

function Clear-DotenvJobs {
Expand Down

0 comments on commit a931c89

Please sign in to comment.