-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #447 from TheJumpCloud/SA-3036_SetJCSystemPipeline
identify pipeline position/ functions
- Loading branch information
Showing
13 changed files
with
124 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
PowerShell/JumpCloud Module/Private/NestedFunctions/Get-PipelineDetails.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Function Get-PipelineDetails { | ||
[CmdletBinding()] | ||
param ( | ||
[Parameter(Mandatory = $true, HelpMessage = 'Pipeline String to test ($myInvocation.line)')] | ||
[System.String] | ||
$line | ||
) | ||
Begin { | ||
$funcArray = @() | ||
# split line by | opperator | ||
$pipelines = $line.split('|') | ||
$pipelineCount = $pipelines.count | ||
} | ||
Process { | ||
foreach ($pipe in $pipelines) { | ||
# trim whitespace | ||
$function = $pipe.replace('{', '').replace('}', '') | ||
$function = $function.TrimStart(" ") | ||
$functionName = $function -match '^([\S]+)' | ||
if ($matches) { | ||
# add functionName $matches[0] and position | ||
$funcArray += [PSCustomObject]@{ | ||
Function = $matches[0]; | ||
Position = $pipelines.IndexOf($pipe) | ||
} | ||
} | ||
} | ||
} | ||
End { | ||
# Return num of piped functions, and the array list of functions & positions | ||
return $pipelineCount, $funcArray | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
PowerShell/JumpCloud Module/Private/NestedFunctions/Get-PipelinePositionBefore.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Function Get-PipelinePositionBefore { | ||
[CmdletBinding()] | ||
param ( | ||
[Parameter(Mandatory = $true, HelpMessage = 'Function name to test pipeline position is directly before function defined in the "after" param')] | ||
[System.String] | ||
$before, | ||
[Parameter(Mandatory = $true, HelpMessage = 'Function name to test pipeline position is directly after function defined in the "before" param')] | ||
[System.String] | ||
$after, | ||
[Parameter(Mandatory = $true, HelpMessage = 'Objects from Get-PipelineDetails')] | ||
[System.object] | ||
$functionArray | ||
) | ||
begin { | ||
$occursBefore = $false | ||
} | ||
process { | ||
# If function in pipeline (n) occurs before n+1, return $true | ||
for ($i = 0; $i -le $functionArray.count; $i++) { | ||
if (($functionArray[$i].Function -match $before) -and ($functionArray[$i + 1].Function -match $after)) { | ||
$occursBefore = $true | ||
} | ||
} | ||
} | ||
end { | ||
return $occursBefore | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters