diff --git a/README.md b/README.md index 2cc890a..ec5f501 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![GitHub workflows (all tests)](https://github.com/wild-devops/pwshake/workflows/all%20tests/badge.svg)](../../actions/workflows/tests.yml) -[![GitHub release (latest by date)](https://img.shields.io/github/v/release/wild-devops/pwshake)](../../releases/tag/v1.5.2) +[![GitHub release (latest by date)](https://img.shields.io/github/v/release/wild-devops/pwshake)](../../releases/tag/v1.5.3) [![PowerShell Gallery](https://img.shields.io/powershellgallery/v/pwshake)](https://www.powershellgallery.com/packages/pwshake) [![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/pwshake)](https://www.powershellgallery.com/packages/pwshake) @@ -123,7 +123,7 @@ invoke_tasks: attributes: pwshake_module_path: /path/to/pwshake/module/source pwshake_path: /absolute/path/to/your/working/directory - pwshake_version: 1.5.2 + pwshake_version: 1.5.3 work_dir: /absolute/path/to/process/working/directory pwshake_log_path: /absolute/path/to/your/working/directory/my_pwshake.log some_attribute: this is an attribute value diff --git a/pwshake/pwshake.psd1 b/pwshake/pwshake.psd1 index a413a7e..f31b204 100644 --- a/pwshake/pwshake.psd1 +++ b/pwshake/pwshake.psd1 @@ -12,7 +12,7 @@ RootModule = 'pwshake.psm1' # Version number of this module. - ModuleVersion = '1.5.2' + ModuleVersion = '1.5.3' # Supported PSEditions # CompatiblePSEditions = @() @@ -52,7 +52,7 @@ # Modules that must be imported into the global environment prior to importing this module RequiredModules = @( - @{ModuleName = "powershell-yaml"; RequiredVersion = "0.4.0"; Guid = "6a75a662-7f53-425a-9777-ee61284407da" } + @{ModuleName = "powershell-yaml"; RequiredVersion = "0.4.2"; Guid = "6a75a662-7f53-425a-9777-ee61284407da" } ) # Assemblies that must be loaded prior to importing this module diff --git a/pwshake/scripts/Interpolate-Attributes.ps1 b/pwshake/scripts/Interpolate-Attributes.ps1 index d440926..b490be7 100644 --- a/pwshake/scripts/Interpolate-Attributes.ps1 +++ b/pwshake/scripts/Interpolate-Attributes.ps1 @@ -13,10 +13,10 @@ function Interpolate-Attributes { do { foreach ($substitute in (Get-Matches $json $regex 'subst')) { "Interpolate-Attributes:$($counter):`$substitute:$substitute" | f-log-dbg - if ($substitute -match '^\$\((?.*)\)$') { + if ($substitute -match '(?ms)^\$\((?.*)\)$') { "Interpolate-Attributes:$($counter):`$eval:{$($matches.eval)}" | f-log-dbg $value = "`"$($matches.eval)`"" | ConvertFrom-Json | Invoke-Expression - } elseif ($substitute -match '^(?\$\S+):(?.*)') { + } elseif ($substitute -match '(?ms)^(?\$\S+?):(?.*)$') { "Interpolate-Attributes:$($counter):`$filter:{$($matches.filter)}:`$input:{$($matches.input)}" | f-log-dbg $value = "`"$($matches.input)`"" | ConvertFrom-Json | & f-$($matches.filter) "Interpolate-Attributes:$($counter):`$value:{$value}" | f-log-dbg diff --git a/tests/Interpolate-Attributes.Context.ps1 b/tests/Interpolate-Attributes.Context.ps1 index 908b22c..f01fa0c 100644 --- a/tests/Interpolate-Attributes.Context.ps1 +++ b/tests/Interpolate-Attributes.Context.ps1 @@ -62,7 +62,7 @@ Context "Interpolate-Attributes" { @{When='{{a}}';And='dev';Then='.dev'} @{When='{{b}}';And='dev';Then='.dev'} ) {param($When, $And, $Then) - $subst = '{{$("' + $When + '" | ? {$_} | % {".$_"})}}' + $subst = '{{$("' + $When + '" | ? {$_} | % {' + [Environment]::NewLine + '".$_"})}}' (Interpolate-Attributes @{ attributes = @{ a = $And @@ -133,4 +133,16 @@ Context "Interpolate-Attributes" { $actual.attributes.b | Should -Be $chars $actual.attributes.c | Should -Be $chars } + + It "Should substitute filters with multiple ':' separators and multiline input" { + $expected = "https://some.url/?other`nvalue1:value2" + + Interpolate-Attributes @{ + attributes = @{a="{{b}}";b='{{$secured:{{c}}}}';c=$expected}; + } | New-Variable -Name actual + + $actual.attributes.a | Should -Be $expected + $actual.attributes.b | Should -Be $expected + $actual.attributes.c | Should -Be $expected + } }