From baa3ccd04d8e1b71f664c828e65269a22f50dad3 Mon Sep 17 00:00:00 2001 From: Gal Szkolnik Date: Thu, 5 Nov 2020 00:00:18 -0500 Subject: [PATCH] Updated MyConfig code to include modules This is a prep for MyModules, a way to notify users that a module installation is recommended for the features of the scripting environment --- profile.d/MyConfig.class.ps1 | 15 +++++++++------ src/modules.json | 7 +++++++ 2 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 src/modules.json diff --git a/profile.d/MyConfig.class.ps1 b/profile.d/MyConfig.class.ps1 index 28d7b2e..4e7c457 100644 --- a/profile.d/MyConfig.class.ps1 +++ b/profile.d/MyConfig.class.ps1 @@ -1,12 +1,15 @@ class MyConfig { #: System.Management.Automation.IValidateSetValuesGenerator { - hidden static [string[]]$_MyConfigDictionaryPath = @( - $(Join-Path $(Join-Path $MyPSScriptRoot 'src') 'config.files.json'), - $(Join-Path $(Join-Path $MyPSScriptRoot 'src') 'config.files.local.json') - ) + hidden static [hashtable]$_HardCodedConfigDict = @{ + 'myconfig' = @($(Join-Path $(Join-Path $MyPSScriptRoot 'src') 'config.files.json'), + $(Join-Path $(Join-Path $MyPSScriptRoot 'src') 'config.files.local.json')) + 'mymodules' = @($(Join-Path $(Join-Path $MyPSScriptRoot 'src') 'modules.json'), + $(Join-Path $(Join-Path $MyPSScriptRoot 'src') 'modules.local.json')) + } + static [hashtable]GetConfigDictionary() { $local:result = @{} - $result['myconfig'] = [MyConfig]::_MyConfigDictionaryPath; - foreach( $local:jsonSource in [MyConfig]::_MyConfigDictionaryPath ) { + [MyConfig]::_HardCodedConfigDict.Keys | ForEach-Object { $result[$_] = [MyConfig]::_HardCodedConfigDict[$_] } + foreach( $local:jsonSource in $result.myconfig ) { if( -not ( Test-Path $jsonSource ) ) { continue } foreach( $local:prop in $(Get-Content $jsonSource | ConvertFrom-Json).PSObject.Properties ) { $result[$prop.Name] = $prop.Value diff --git a/src/modules.json b/src/modules.json new file mode 100644 index 0000000..2bd93a2 --- /dev/null +++ b/src/modules.json @@ -0,0 +1,7 @@ +{ + "Modules": [ + "Microsoft.PowerShell.UnixCompleters", + "oh-my-posh", + "posh-git" + ] +}