Skip to content

Commit

Permalink
!deploy v0.5.0 ready for release (#20)
Browse files Browse the repository at this point in the history
## 0.5.0 - 2019-10-08

* Miscellaneous
    * Added FileWatcher event registration to update current `$global:PSProfile` object whenever the Configuration.psd1 file has changed, enabling configuration persistence across sessions. Configuration additions and removals from one PowerShell session will immediately be reflected in other active sessions.
    * Removed the persistence workaround the `Save()` method in favor of the Configuration.psd1 FileWatcher method.
  • Loading branch information
scrthq authored Oct 9, 2019
2 parents d340408 + d8f8fd1 commit 0532a48
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
* [PSProfile - ChangeLog](#psprofile---changelog)
* [0.5.0 - 2019-10-08](#050---2019-10-08)
* [0.4.1 - 2019-10-08](#041---2019-10-08)
* [0.4.0 - 2019-09-22](#040---2019-09-22)
* [0.3.0 - 2019-09-07](#030---2019-09-07)
Expand All @@ -18,6 +19,12 @@

# PSProfile - ChangeLog

## 0.5.0 - 2019-10-08

* Miscellaneous
* Added FileWatcher event registration to update current `$global:PSProfile` object whenever the Configuration.psd1 file has changed, enabling configuration persistence across sessions. Configuration additions and removals from one PowerShell session will immediately be reflected in other active sessions.
* Removed the persistence workaround the `Save()` method in favor of the Configuration.psd1 FileWatcher method.

## 0.4.1 - 2019-10-08

* Miscellaneous
Expand Down
11 changes: 1 addition & 10 deletions PSProfile/Classes/PSProfile.Classes.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,6 @@ if ($env:AWS_PROFILE) {
"MAIN",
"Debug"
)
$conf = Import-Configuration -Name PSProfile -CompanyName 'SCRT HQ' -DefaultPath (Join-Path $PSScriptRoot "Configuration.psd1")
if ($conf.LastSave -gt $this.LastSave) {
$this._log(
"Configuration has been updated from another session @ $($conf.LastSave). Pulling in updated configuration before saving.",
"MAIN",
"Verbose"
)
$this | Update-Object $conf
}
$out = @{ }
$this.LastSave = [DateTime]::Now
$this.PSObject.Properties.Name | Where-Object { $_ -ne '_internal' } | ForEach-Object {
Expand All @@ -330,7 +321,7 @@ if ($env:AWS_PROFILE) {
$this._log(
"PSProfile configuration has been saved.",
"MAIN",
"Verbose"
"Debug"
)
}
hidden [string] _globalize([string]$content) {
Expand Down
2 changes: 1 addition & 1 deletion PSProfile/PSProfile.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'PSProfile.psm1'

# Version number of this module.
ModuleVersion = '0.4.0'
ModuleVersion = '0.5.0'

# Supported PSEditions
CompatiblePSEditions = @('Desktop','Core')
Expand Down
20 changes: 19 additions & 1 deletion PSProfile/PSProfile.psm1
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
# If we're in an interactive shell, load the profile.
if ([Environment]::UserInteractive -or ($null -eq [Environment]::UserInteractive -and $null -eq ([Environment]::GetCommandLineArgs() | Where-Object {$_ -like '-NonI*'}))) {
if ([Environment]::UserInteractive -or ($null -eq [Environment]::UserInteractive -and $null -eq ([Environment]::GetCommandLineArgs() | Where-Object { $_ -like '-NonI*' }))) {
$global:OriginalPrompt =
$global:PSProfile = [PSProfile]::new()
$global:PSProfile.Load()
Export-ModuleMember -Variable PSProfile
$global:PSProfileConfigurationWatcher = [System.IO.FileSystemWatcher]::new($(Split-Path $global:PSProfile.Settings.ConfigurationPath -Parent),'Configuration.psd1')
$job = Register-ObjectEvent -InputObject $global:PSProfileConfigurationWatcher -EventName Changed -Action {
[PSProfile]$conf = Import-Configuration -Name PSProfile -CompanyName 'SCRT HQ' -Verbose:$false
$conf._internal = $global:PSProfile._internal
$global:PSProfile = $conf
}
$PSProfile_OnRemoveScript = {
try {
$global:PSProfileConfigurationWatcher.Dispose()
}
finally {
Remove-Variable PSProfile -Scope Global -Force
Remove-Variable PSProfileConfigurationWatcher -Scope Global -Force
}
}
$ExecutionContext.SessionState.Module.OnRemove += $PSProfile_OnRemoveScript
Register-EngineEvent -SourceIdentifier ([System.Management.Automation.PsEngineEvent]::Exiting) -Action $PSProfile_OnRemoveScript
}
1 change: 0 additions & 1 deletion invoke.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ task Test Init,{
$testResults | Format-List
Write-BuildError 'One or more Pester tests failed. Build cannot continue!'
}
Pop-Location
}

$psGalleryConditions = {
Expand Down

0 comments on commit 0532a48

Please sign in to comment.