Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ function Test_UpdateProjectWithInjection{
}
}

MockCallToObject -Command 'Invoke-ProjectInjectionFunctions' -OutObject @("Invoke-ProjectInjection_1","Invoke-ProjectInjection_2")

# Act
$result = Update-ProjectItemsWithInjection -owner $Owner -ProjectNumber $ProjectNumber

Expand Down Expand Up @@ -132,6 +134,8 @@ function Test_UpdateProjectWithInjection_Failed_1{
throw "Integration 2 failed"
}

MockCallToObject -Command 'Invoke-ProjectInjectionFunctions' -OutObject @("Invoke-ProjectInjection_1","Invoke-ProjectInjection_2")

# Act
$result = Update-ProjectItemsWithInjection -Owner $Owner -ProjectNumber $ProjectNumber

Expand Down
25 changes: 10 additions & 15 deletions public/integrations/update-ProjectItemsWithInjection.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

Set-MyInvokeCommandAlias -Alias GetInvokeProjectInjectionFunctions -Command 'Invoke-ProjectInjectionFunctions'

<#
.SYNOPSIS
Updates project items with injection functions.
Expand Down Expand Up @@ -35,8 +38,7 @@
$project = Get-Project -Owner $Owner -ProjectNumber $ProjectNumber -Force:(-not $SkipStagedCheck)

# Get the injection functions list

$functions = Get-ProjectInjectionFunctions
$functions = Invoke-MyCommand GetInvokeProjectInjectionFunctions

# Iterate through all the items in the project
$start = Get-Date
Expand All @@ -46,7 +48,7 @@
# Add extra info to result
$result | Add-Member -NotePropertyName "Integrations" -NotePropertyValue $functions.count
$result | Add-Member -NotePropertyName "Time" -NotePropertyValue $time
$result | Add-Member -NotePropertyName "IntegrationsName" -NotePropertyValue $functions.Name
$result | Add-Member -NotePropertyName "IntegrationsName" -NotePropertyValue $functions


# Save result to global variable
Expand All @@ -57,20 +59,21 @@

} Export-ModuleMember -Function Update-ProjectItemsWithInjection

function Get-ProjectInjectionFunctions {
function Invoke-ProjectInjectionFunctions {

Check notice

Code scanning / PSScriptAnalyzer

The cmdlet 'Invoke-ProjectInjectionFunctions' does not have a help comment. Note

The cmdlet 'Invoke-ProjectInjectionFunctions' does not have a help comment.

Check warning

Code scanning / PSScriptAnalyzer

The cmdlet 'Invoke-ProjectInjectionFunctions' uses a plural noun. A singular noun should be used instead. Warning

The cmdlet 'Invoke-ProjectInjectionFunctions' uses a plural noun. A singular noun should be used instead.
[CmdletBinding()]
param()

$functions = 'Get-Command -Name "Invoke-ProjectInjection_*" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty name'

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
# Get all functions that start with Invoke-ProjectInjection_
$functions = Get-Command -Name "Invoke-ProjectInjection_*" -ErrorAction SilentlyContinue

if ($functions) {
return $functions
} else {
Write-Host "No project injection functions found." -ForegroundColor Yellow
return $null
}
} Export-ModuleMember -Function Get-ProjectInjectionFunctions
} Export-ModuleMember -Function Invoke-ProjectInjectionFunctions


<#.SYNOPSIS
Expand Down Expand Up @@ -99,8 +102,7 @@
function Invoke-ProjectInjection {
[CmdletBinding()]
param (
[parameter(ValueFromPipeline)][System.Management.Automation.FunctionInfo] $FunctionInfo,
[Parameter()] [string] $FunctionName,
[parameter(Mandatory,ValueFromPipeline)][string] $FunctionName,
[Parameter(Position = 0)] [string]$Owner,
[Parameter(Position = 1)] [string]$ProjectNumber,
[Parameter()] [switch] $ShowErrors
Expand All @@ -126,13 +128,6 @@
$ErrorShow = 'SilentlyContinue'
}

if ($FunctionInfo) {
$FunctionName = $FunctionInfo.Name
} elseif (-not $FunctionName) {
Write-Error "FunctionName is required when FunctionInfo is not provided."
return
}

Write-Verbose -Message "Running [ $FunctionName ]"

try {
Expand Down