Skip to content

Commit

Permalink
Set PositionalBinding to $false when mocking cmdlet
Browse files Browse the repository at this point in the history
  • Loading branch information
PetSerAl committed Feb 21, 2016
1 parent 676818a commit b079e62
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Functions/Mock.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,13 @@ about_Mocking
}

$cmdletBinding = [Management.Automation.ProxyCommand]::GetCmdletBindingAttribute($metadata)
if ($global:PSVersionTable.PSVersion.Major -ge 3 -and $contextInfo.Command.CommandType -eq 'Cmdlet') {
if ($cmdletBinding -ne '[CmdletBinding()]') {
$cmdletBinding = $cmdletBinding.Insert($cmdletBinding.Length-2, ',')
}
$cmdletBinding = $cmdletBinding.Insert($cmdletBinding.Length-2, 'PositionalBinding=$false')
}

$paramBlock = [Management.Automation.ProxyCommand]::GetParamBlock($metadata)

if ($contextInfo.Command.CommandType -eq 'Cmdlet')
Expand Down

0 comments on commit b079e62

Please sign in to comment.