Skip to content

Commit 0532a48

Browse files
authored
!deploy v0.5.0 ready for release (#20)
## 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.
2 parents d340408 + d8f8fd1 commit 0532a48

File tree

5 files changed

+28
-13
lines changed

5 files changed

+28
-13
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
* [PSProfile - ChangeLog](#psprofile---changelog)
2+
* [0.5.0 - 2019-10-08](#050---2019-10-08)
23
* [0.4.1 - 2019-10-08](#041---2019-10-08)
34
* [0.4.0 - 2019-09-22](#040---2019-09-22)
45
* [0.3.0 - 2019-09-07](#030---2019-09-07)
@@ -18,6 +19,12 @@
1819

1920
# PSProfile - ChangeLog
2021

22+
## 0.5.0 - 2019-10-08
23+
24+
* Miscellaneous
25+
* 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.
26+
* Removed the persistence workaround the `Save()` method in favor of the Configuration.psd1 FileWatcher method.
27+
2128
## 0.4.1 - 2019-10-08
2229

2330
* Miscellaneous

PSProfile/Classes/PSProfile.Classes.ps1

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -312,15 +312,6 @@ if ($env:AWS_PROFILE) {
312312
"MAIN",
313313
"Debug"
314314
)
315-
$conf = Import-Configuration -Name PSProfile -CompanyName 'SCRT HQ' -DefaultPath (Join-Path $PSScriptRoot "Configuration.psd1")
316-
if ($conf.LastSave -gt $this.LastSave) {
317-
$this._log(
318-
"Configuration has been updated from another session @ $($conf.LastSave). Pulling in updated configuration before saving.",
319-
"MAIN",
320-
"Verbose"
321-
)
322-
$this | Update-Object $conf
323-
}
324315
$out = @{ }
325316
$this.LastSave = [DateTime]::Now
326317
$this.PSObject.Properties.Name | Where-Object { $_ -ne '_internal' } | ForEach-Object {
@@ -330,7 +321,7 @@ if ($env:AWS_PROFILE) {
330321
$this._log(
331322
"PSProfile configuration has been saved.",
332323
"MAIN",
333-
"Verbose"
324+
"Debug"
334325
)
335326
}
336327
hidden [string] _globalize([string]$content) {

PSProfile/PSProfile.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'PSProfile.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '0.4.0'
15+
ModuleVersion = '0.5.0'
1616

1717
# Supported PSEditions
1818
CompatiblePSEditions = @('Desktop','Core')

PSProfile/PSProfile.psm1

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
# If we're in an interactive shell, load the profile.
2-
if ([Environment]::UserInteractive -or ($null -eq [Environment]::UserInteractive -and $null -eq ([Environment]::GetCommandLineArgs() | Where-Object {$_ -like '-NonI*'}))) {
2+
if ([Environment]::UserInteractive -or ($null -eq [Environment]::UserInteractive -and $null -eq ([Environment]::GetCommandLineArgs() | Where-Object { $_ -like '-NonI*' }))) {
3+
$global:OriginalPrompt =
34
$global:PSProfile = [PSProfile]::new()
45
$global:PSProfile.Load()
56
Export-ModuleMember -Variable PSProfile
7+
$global:PSProfileConfigurationWatcher = [System.IO.FileSystemWatcher]::new($(Split-Path $global:PSProfile.Settings.ConfigurationPath -Parent),'Configuration.psd1')
8+
$job = Register-ObjectEvent -InputObject $global:PSProfileConfigurationWatcher -EventName Changed -Action {
9+
[PSProfile]$conf = Import-Configuration -Name PSProfile -CompanyName 'SCRT HQ' -Verbose:$false
10+
$conf._internal = $global:PSProfile._internal
11+
$global:PSProfile = $conf
12+
}
13+
$PSProfile_OnRemoveScript = {
14+
try {
15+
$global:PSProfileConfigurationWatcher.Dispose()
16+
}
17+
finally {
18+
Remove-Variable PSProfile -Scope Global -Force
19+
Remove-Variable PSProfileConfigurationWatcher -Scope Global -Force
20+
}
21+
}
22+
$ExecutionContext.SessionState.Module.OnRemove += $PSProfile_OnRemoveScript
23+
Register-EngineEvent -SourceIdentifier ([System.Management.Automation.PsEngineEvent]::Exiting) -Action $PSProfile_OnRemoveScript
624
}

invoke.build.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ task Test Init,{
217217
$testResults | Format-List
218218
Write-BuildError 'One or more Pester tests failed. Build cannot continue!'
219219
}
220-
Pop-Location
221220
}
222221

223222
$psGalleryConditions = {

0 commit comments

Comments
 (0)