File tree Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55The format is based on [ Keep a Changelog] ( http://keepachangelog.com/ )
66and this project adheres to [ Semantic Versioning] ( http://semver.org/ ) .
77
8+ ## [ 0.7.1] Unreleased
9+
10+ ### Fixed
11+
12+ - Set default preferences if the preferences XML file cannot be parsed for any reason.
13+
814## [ 0.7.0] 2021-11-10
915
1016### Added
Original file line number Diff line number Diff line change @@ -9,14 +9,23 @@ function Import-Preferences {
99 [string ]$DefaultThemeName = $script :defaultTheme
1010 )
1111
12+ begin {
13+ $defaultPrefs = @ {
14+ CurrentColorTheme = $DefaultThemeName
15+ CurrentIconTheme = $DefaultThemeName
16+ }
17+ }
18+
1219 process {
1320 if (Test-Path $Path ) {
14- Import-Clixml - Path $Path
15- } else {
16- @ {
17- CurrentColorTheme = $DefaultThemeName
18- CurrentIconTheme = $DefaultThemeName
21+ try {
22+ Import-Clixml - Path $Path - ErrorAction Stop
23+ } catch {
24+ Write-Warning " Unable to parse [ $Path ]. Setting default preferences. "
25+ $defaultPrefs
1926 }
27+ } else {
28+ $defaultPrefs
2029 }
2130 }
2231}
You can’t perform that action at this time.
0 commit comments