feat(core): Merge-PackageControlSettings hash
- This function used to only accept a file, but can now accept a hash - This allows for easily configuring pre-release version of Sublime to auto-update
This commit is contained in:
@@ -120,6 +120,9 @@ function Install-SublimePackageControl
|
|||||||
$packageUrl = 'https://sublime.wbond.net/prerelease/Package%20Control.sublime-package'
|
$packageUrl = 'https://sublime.wbond.net/prerelease/Package%20Control.sublime-package'
|
||||||
}
|
}
|
||||||
Get-ChocolateyWebFile -url $packageUrl -fileFullPath $packageControl
|
Get-ChocolateyWebFile -url $packageUrl -fileFullPath $packageControl
|
||||||
|
|
||||||
|
$settings = @{ 'install_prereleases' = $PreRelease }
|
||||||
|
Merge-PackageControlSettings -Settings $settings -Version $Version
|
||||||
}
|
}
|
||||||
|
|
||||||
3 {
|
3 {
|
||||||
@@ -132,12 +135,16 @@ function Install-SublimePackageControl
|
|||||||
|
|
||||||
function Merge-PackageControlSettings
|
function Merge-PackageControlSettings
|
||||||
{
|
{
|
||||||
[CmdletBinding()]
|
[CmdletBinding(DefaultParameterSetName = "File")]
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $false, ParameterSetName = "File")]
|
||||||
[string]
|
[string]
|
||||||
$FilePath,
|
$FilePath,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false, ParameterSetName = "Hash")]
|
||||||
|
[Hashtable]
|
||||||
|
$Settings,
|
||||||
|
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
[ValidateRange(2,3)]
|
[ValidateRange(2,3)]
|
||||||
[int]
|
[int]
|
||||||
@@ -156,7 +163,14 @@ function Merge-PackageControlSettings
|
|||||||
$existing = ConvertFrom-Json $existingText
|
$existing = ConvertFrom-Json $existingText
|
||||||
Write-Verbose "Existing settings: `n`n$existingText`n`n"
|
Write-Verbose "Existing settings: `n`n$existingText`n`n"
|
||||||
|
|
||||||
$new = ConvertFrom-Json ([IO.File]::ReadAllText($FilePath))
|
if ($PsCmdlet.ParameterSetName -eq 'File')
|
||||||
|
{
|
||||||
|
$new = ConvertFrom-Json ([IO.File]::ReadAllText($FilePath))
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$new = $Settings
|
||||||
|
}
|
||||||
|
|
||||||
$simpleArrays = @('installed_packages', 'repositories', 'channels',
|
$simpleArrays = @('installed_packages', 'repositories', 'channels',
|
||||||
'auto_upgrade_ignore', 'git_update_command', 'hg_update_command',
|
'auto_upgrade_ignore', 'git_update_command', 'hg_update_command',
|
||||||
@@ -177,7 +191,9 @@ function Merge-PackageControlSettings
|
|||||||
% { Merge-JsonArrayOfSimpleMap -Name $_ -Destination $existing -Array $new.$_ }
|
% { Merge-JsonArrayOfSimpleMap -Name $_ -Destination $existing -Array $new.$_ }
|
||||||
|
|
||||||
$excluded = $simpleArrays + $maps + $arrayOfMaps
|
$excluded = $simpleArrays + $maps + $arrayOfMaps
|
||||||
$new.PSObject.Properties |
|
if ($new -is [PSCustomObject]) { $props = $new.PSObject.Properties }
|
||||||
|
else { $props = $new.GetEnumerator() }
|
||||||
|
$props |
|
||||||
? { $excluded -inotcontains $_.Name } |
|
? { $excluded -inotcontains $_.Name } |
|
||||||
% {
|
% {
|
||||||
Merge-JsonNamedValue -Name $_.Name -Destination $existing -Value $_.Value
|
Merge-JsonNamedValue -Name $_.Name -Destination $existing -Value $_.Value
|
||||||
|
Reference in New Issue
Block a user