Skip to content

Commit a022cec

Browse files
committed
refactor(format): better filtering of deleted items
1 parent ea8bf94 commit a022cec

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

build/tasks/tasks-powershell/powershell.format.tasks.ps1

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@ Task powershell-format-code {
33
$PSScriptAnalyzerExclusions = '(artifacts)|(packages)'
44
$Settings = Join-Path $BuildRoot 'build/settings/powershell-formatting-settings.psd1'
55
Write-Build DarkGray 'Applying Formatting to All PS1 Files'
6-
$files = & git diff --name-only --diff-filter=d | Where-Object { $_ -like '*.ps1' } |
7-
ForEach-Object { Get-Item -Path $_ } |
8-
Where-Object FullName -NotMatch $PSScriptAnalyzerExclusions
6+
$files = & git status --porcelain | Where-Object { $_ -notmatch '^D' } |
7+
ForEach-Object { $_.TrimStart('ADMR ') } |
8+
ForEach-Object { Get-Item -Path $_ } |
9+
Where-Object { $_ -like '*.ps1' } |
10+
Where-Object FullName -NotMatch $PSScriptAnalyzerExclusions
911
Write-Build DarkGray "Total Files to Process: $(@($Files).Count)"
1012
$x = 0
1113
$id = Get-Random
1214
Write-Progress -Id $id -Activity 'Formatting Files' -PercentComplete 0
1315
$files | ForEach-Object {
1416
$f = $_
1517
[string]$content = ([System.IO.File]::ReadAllText($f.FullName)).Trim()
16-
if (-not $Content)
17-
{
18+
if (-not $Content) {
1819
Write-Build DarkGray "Bypassed: $($f.Name) per empty"
1920
continue
2021
}

0 commit comments

Comments
 (0)