core.substitute() for arrays (#2048)

This commit is contained in:
Vladimir Chebotarev
2018-02-26 14:09:11 +01:00
committed by Richard Kuhnt
parent 51a780e299
commit 128262191b
+8 -4
View File
@@ -450,11 +450,15 @@ function is_scoop_outdated() {
return $last_update -lt $now.ToLocalTime()
}
function substitute([String] $str, [Hashtable] $params) {
$params.GetEnumerator() | % {
$str = $str.Replace($_.Name, $_.Value)
function substitute($entity, [Hashtable] $params) {
if ($entity -is [Array]) {
return $entity | % { substitute $_ $params }
} elseif ($entity -is [String]) {
$params.GetEnumerator() | % {
$entity = $entity.Replace($_.Name, $_.Value)
}
return $entity
}
return $str
}
function format_hash([String] $hash) {