File tree Expand file tree Collapse file tree
PSModuleDevelopment/functions/refactor Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4040 . PARAMETER NoAlias
4141 Avoid creating an alias for the old parameter name.
4242 This may cause a breaking change!
43+
44+ . PARAMETER WhatIf
45+ Prevents the command from updating the files.
46+ Instead it will return the strings of all its changes.
4347
4448 . PARAMETER EnableException
4549 Replaces user friendly yellow warnings with bloody red exceptions of doom!
7680 [switch ]
7781 $NoAlias ,
7882
83+ [switch ]
84+ $WhatIf ,
85+
7986 [switch ]
8087 $EnableException ,
8188
240247 {
241248 Add-FileReplacement - Path $Ast.Extent.File - Start $Ast.Extent.StartOffset - Length ($Ast.Extent.EndOffset - $Ast.Extent.StartOffset ) - NewContent " `$ $NewName "
242249 }
243-
250+ }
251+ " System.Management.Automation.Language.IfStatementAst"
252+ {
253+ foreach ($clause in $Ast.Clauses )
254+ {
255+ Invoke-AstWalk - Ast $clause.Item1 - Command $Command - Name $Name - NewName $NewName - IsCommand $IsCommand - NoAlias $NoAlias
256+ Invoke-AstWalk - Ast $clause.Item2 - Command $Command - Name $Name - NewName $NewName - IsCommand $IsCommand - NoAlias $NoAlias
257+ }
258+ if ($Ast.ElseClause )
259+ {
260+ Invoke-AstWalk - Ast $Ast.ElseClause - Command $Command - Name $Name - NewName $NewName - IsCommand $IsCommand - NoAlias $NoAlias
261+ }
244262 }
245263 default
246264 {
390408 {
391409 [CmdletBinding ()]
392410 Param (
393-
411+ [bool ]
412+ $WhatIf
394413 )
395414
396415 foreach ($key in $globalFunctionHash.Keys )
410429
411430 $newString += $content.SubString ($currentIndex )
412431
413- [ System.IO.File ]::WriteAllText( $key , $newString )
414- # $ newString
432+ if ( $WhatIf ) { $newString }
433+ else { [ System.IO.File ]::WriteAllText( $key , $ newString) }
415434 }
416435 }
417436
478497 }
479498
480499 Set-PSFResultCache - InputObject $issues - DisableCache $DisableCache
481- Apply- FileReplacement
500+ Apply- FileReplacement - WhatIf $WhatIf
482501 $issues
483502}
You can’t perform that action at this time.
0 commit comments