From 666a12a65f9855d9f2b5d81182863b26d39d200b Mon Sep 17 00:00:00 2001 From: Friedrich Weinmann Date: Sun, 10 Jan 2021 12:38:58 +0100 Subject: [PATCH] strings: Adding support for Test-PSFShouldProcess --- PSModuleDevelopment/changelog.md | 1 + .../functions/refactor/Convert-PSMDMessage.ps1 | 2 +- PSModuleDevelopment/functions/refactor/Export-PSMDString.ps1 | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/PSModuleDevelopment/changelog.md b/PSModuleDevelopment/changelog.md index 4ea0262..c25876a 100644 --- a/PSModuleDevelopment/changelog.md +++ b/PSModuleDevelopment/changelog.md @@ -3,6 +3,7 @@ ## ??? - New: Convert-PSMDMessage - Converts a file's use of PSFramework messages to strings. +- Upd: Export-PSMDString - Adding support for Test-PSFShouldProcess. - Fix: Export-PSMDString - Failed with splatting detection ## 2.2.8.104 (July 26th, 2020) diff --git a/PSModuleDevelopment/functions/refactor/Convert-PSMDMessage.ps1 b/PSModuleDevelopment/functions/refactor/Convert-PSMDMessage.ps1 index fa48a69..720f27f 100644 --- a/PSModuleDevelopment/functions/refactor/Convert-PSMDMessage.ps1 +++ b/PSModuleDevelopment/functions/refactor/Convert-PSMDMessage.ps1 @@ -125,7 +125,7 @@ $commandAsts = $ast.FindAll({ if ($args[0] -isnot [System.Management.Automation.Language.CommandAst]) { return $false } - if ($args[0].CommandElements[0].Value -notmatch '^Invoke-PSFProtectedCommand$|^Write-PSFMessage$|^Stop-PSFFunction$') { return $false } + if ($args[0].CommandElements[0].Value -notmatch '^Invoke-PSFProtectedCommand$|^Write-PSFMessage$|^Stop-PSFFunction$|^Test-PSFShouldProcess$') { return $false } if (-not ($args[0].CommandElements.ParameterName -match '^Message$|^Action$')) { return $false } $true }, $true) diff --git a/PSModuleDevelopment/functions/refactor/Export-PSMDString.ps1 b/PSModuleDevelopment/functions/refactor/Export-PSMDString.ps1 index fbf020a..52b16b6 100644 --- a/PSModuleDevelopment/functions/refactor/Export-PSMDString.ps1 +++ b/PSModuleDevelopment/functions/refactor/Export-PSMDString.ps1 @@ -48,7 +48,7 @@ #region Command Parameters $commandAsts = $ast.FindAll({ if ($args[0] -isnot [System.Management.Automation.Language.CommandAst]) { return $false } - if ($args[0].CommandElements[0].Value -notmatch '^Invoke-PSFProtectedCommand$|^Write-PSFMessage$|^Stop-PSFFunction$') { return $false } + if ($args[0].CommandElements[0].Value -notmatch '^Invoke-PSFProtectedCommand$|^Write-PSFMessage$|^Stop-PSFFunction$|^Test-PSFShouldProcess$') { return $false } if (-not ($args[0].CommandElements.ParameterName -match '^String$|^ActionString$')) { return $false } $true }, $true) @@ -79,7 +79,7 @@ $splattedVariables = $ast.FindAll({ if ($args[0] -isnot [System.Management.Automation.Language.VariableExpressionAst]) { return $false } if (-not ($args[0].Splatted -eq $true)) { return $false } - try { if ($args[0].Parent.CommandElements[0].Value -notmatch '^Invoke-PSFProtectedCommand$|^Write-PSFMessage$|^Stop-PSFFunction$') { return $false } } + try { if ($args[0].Parent.CommandElements[0].Value -notmatch '^Invoke-PSFProtectedCommand$|^Write-PSFMessage$|^Stop-PSFFunction$|^Test-PSFShouldProcess$') { return $false } } catch { return $false } $true }, $true)