1- # region Piecemeal [ 0.3.3 ] : Easy Extensible Plugins for PowerShell
1+ # region Piecemeal [ 0.3.4 ] : Easy Extensible Plugins for PowerShell
22# Install-Module Piecemeal -Scope CurrentUser
33# Import-Module Piecemeal -Force
44# Install-Piecemeal -ExtensionNoun 'PipeScript' -ExtensionPattern '\.psx\.ps1{0,1}$','\.ps1{0,1}\.(?<ext>[^.]+$)','\.ps1{0,1}$' -ExtensionTypeName 'PipeScript' -OutputPath '.\Get-PipeScript.ps1'
@@ -230,7 +230,7 @@ function Get-PipeScript
230230 }
231231
232232 $extCmd.PSObject.Methods.Add ([psscriptmethod ]::new(' GetExtendedCommands' , {
233-
233+ param ([ Management.Automation.CommandInfo []] $CommandList )
234234 $extendedCommandNames = @ (
235235 foreach ($attr in $this.ScriptBlock.Attributes ) {
236236 if ($attr -isnot [Management.Automation.CmdletAttribute ]) { continue }
@@ -244,13 +244,16 @@ function Get-PipeScript
244244 $this | Add-Member NoteProperty ExtensionCommands @ () - Force
245245 return
246246 }
247- $allLoadedCmds = $ExecutionContext.SessionState.InvokeCommand.GetCommands (' *' , ' All' , $true )
247+ if (-not $CommandList ) {
248+ $commandList = $ExecutionContext.SessionState.InvokeCommand.GetCommands (' *' , ' Function,Alias,Cmdlet' , $true )
249+ }
248250 $extends = @ {}
249- foreach ($loadedCmd in $allLoadedCmds ) {
251+ :nextCommand foreach ($loadedCmd in $commandList ) {
250252 foreach ($extensionCommandName in $extendedCommandNames ) {
251253 if ($extensionCommandName -and $loadedCmd.Name -match $extensionCommandName ) {
252254 $loadedCmd
253255 $extends [$loadedCmd.Name ] = $loadedCmd
256+ continue nextCommand
254257 }
255258 }
256259 }
@@ -263,7 +266,12 @@ function Get-PipeScript
263266 $this | Add-Member NoteProperty ExtensionCommands $extends.Values - Force
264267 }))
265268
266- $null = $extCmd.GetExtendedCommands ()
269+ if (-not $script :AllCommands ) {
270+ $script :AllCommands = $ExecutionContext.SessionState.InvokeCommand.GetCommands (' *' , ' Function,Alias,Cmdlet' , $true )
271+ }
272+
273+
274+ $null = $extCmd.GetExtendedCommands ($script :AllCommands )
267275
268276 $inheritanceLevel = [ComponentModel.InheritanceLevel ]::Inherited
269277
@@ -824,9 +832,8 @@ function Get-PipeScript
824832 return $allDynamicParameters
825833 }
826834 }
827- }
828- # endregion Define Inner Functions
829-
835+ }
836+ # endregion Define Inner Functions
830837
831838 $extensionFullRegex =
832839 [Regex ]::New($ (
@@ -847,7 +854,8 @@ function Get-PipeScript
847854 $getCmd = $ExecutionContext.SessionState.InvokeCommand.GetCommand
848855
849856 if ($Force ) {
850- $script :PipeScripts = $null
857+ $script :PipeScripts = $null
858+ $script :AllCommands = @ ()
851859 }
852860 if (-not $script :PipeScripts )
853861 {
@@ -917,5 +925,5 @@ function Get-PipeScript
917925 }
918926 }
919927}
920- # endregion Piecemeal [ 0.3.3 ] : Easy Extensible Plugins for PowerShell
928+ # endregion Piecemeal [ 0.3.4 ] : Easy Extensible Plugins for PowerShell
921929
0 commit comments