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
This commit is contained in:
parent
f00e9090a5
commit
baa3ccd04d
|
@ -1,12 +1,15 @@
|
||||||
class MyConfig { #: System.Management.Automation.IValidateSetValuesGenerator {
|
class MyConfig { #: System.Management.Automation.IValidateSetValuesGenerator {
|
||||||
hidden static [string[]]$_MyConfigDictionaryPath = @(
|
hidden static [hashtable]$_HardCodedConfigDict = @{
|
||||||
$(Join-Path $(Join-Path $MyPSScriptRoot 'src') 'config.files.json'),
|
'myconfig' = @($(Join-Path $(Join-Path $MyPSScriptRoot 'src') 'config.files.json'),
|
||||||
$(Join-Path $(Join-Path $MyPSScriptRoot 'src') 'config.files.local.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() {
|
static [hashtable]GetConfigDictionary() {
|
||||||
$local:result = @{}
|
$local:result = @{}
|
||||||
$result['myconfig'] = [MyConfig]::_MyConfigDictionaryPath;
|
[MyConfig]::_HardCodedConfigDict.Keys | ForEach-Object { $result[$_] = [MyConfig]::_HardCodedConfigDict[$_] }
|
||||||
foreach( $local:jsonSource in [MyConfig]::_MyConfigDictionaryPath ) {
|
foreach( $local:jsonSource in $result.myconfig ) {
|
||||||
if( -not ( Test-Path $jsonSource ) ) { continue }
|
if( -not ( Test-Path $jsonSource ) ) { continue }
|
||||||
foreach( $local:prop in $(Get-Content $jsonSource | ConvertFrom-Json).PSObject.Properties ) {
|
foreach( $local:prop in $(Get-Content $jsonSource | ConvertFrom-Json).PSObject.Properties ) {
|
||||||
$result[$prop.Name] = $prop.Value
|
$result[$prop.Name] = $prop.Value
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"Modules": [
|
||||||
|
"Microsoft.PowerShell.UnixCompleters",
|
||||||
|
"oh-my-posh",
|
||||||
|
"posh-git"
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue