|
2 | 2 | { |
3 | 3 | <# |
4 | 4 | .Synopsis |
5 | | - Uses PipeScript Transpilers |
| 5 | + Uses PipeScript Transpilers |
6 | 6 | .Description |
7 | 7 | Runs an individual PipeScript Transpiler. |
8 | 8 | This command must be used by it's smart aliases (for example ```.>PipeScript```). |
|
35 | 35 | { |
36 | 36 | $matches.Name |
37 | 37 | } |
38 | | - else |
| 38 | + elseif ($MyInv.InvocationName) |
39 | 39 | { |
40 | 40 | $myInv.InvocationName -replace $NameRegex, '${Name}' |
41 | 41 | } |
| 42 | + else { |
| 43 | + $callstackPeek = @(Get-PSCallStack)[-1] |
| 44 | + $callerCommand = $callstackPeek.InvocationInfo.MyCommand.ToString() |
| 45 | + $CallerName = |
| 46 | + if ($callerCommand -match "-Name\s{0,1}(?<Name>\S+)") { |
| 47 | + $matches.Name |
| 48 | + } elseif ($callerCommand -match '(?>gcm|Get-Command)\s{0,1}(?<Name>\S+)') { |
| 49 | + $matches.Name |
| 50 | + } |
| 51 | + |
| 52 | + if ($callerName) { |
| 53 | + $callerName -replace $NameRegex, '${Name}' |
| 54 | + } |
| 55 | + } |
| 56 | + |
| 57 | + if (-not $mySafeName) { return } |
42 | 58 |
|
43 | 59 | # Find the Converter in the library. |
44 | | - $converter = Get-Transpiler | Where-Object DisplayName -eq $mySafeName |
45 | | - $converter.GetDynamicParameters() |
46 | | - # return $Converter.GetDynamicParameters() |
| 60 | + $converter = Get-Transpiler | Where-Object DisplayName -eq $mySafeName |
| 61 | + if ($converter) { |
| 62 | + $converter.GetDynamicParameters() |
| 63 | + } |
| 64 | + |
47 | 65 | } |
48 | 66 |
|
49 | 67 | begin { |
50 | | - $steppablePipelines = |
| 68 | + $steppablePipelines = |
51 | 69 | @(if (-not $mySafeName -and $psBoundParameters['Name']) { |
52 | 70 | $names = $psBoundParameters['Name'] |
53 | 71 | $null = $psBoundParameters.Remove('Name') |
|
61 | 79 | } |
62 | 80 |
|
63 | 81 | process { |
64 | | - if (-not $mySafeName -and -not $steppablePipelines) { |
| 82 | + if (-not $mySafeName -and -not $steppablePipelines) { |
65 | 83 | Write-Error "Must call Use-Pipescript with one of it's aliases." |
66 | 84 | return |
67 | | - } |
| 85 | + } |
68 | 86 | elseif ($steppablePipelines) { |
69 | 87 | $in = $_ |
70 | 88 | foreach ($sp in $steppablePipelines) { |
|
0 commit comments