Skip to content

Commit

Permalink
refactor(format): better filtering of deleted items
Browse files Browse the repository at this point in the history
  • Loading branch information
sheldonhull committed Jul 31, 2023
1 parent ea8bf94 commit a022cec
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions build/tasks/tasks-powershell/powershell.format.tasks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ Task powershell-format-code {
$PSScriptAnalyzerExclusions = '(artifacts)|(packages)'
$Settings = Join-Path $BuildRoot 'build/settings/powershell-formatting-settings.psd1'
Write-Build DarkGray 'Applying Formatting to All PS1 Files'
$files = & git diff --name-only --diff-filter=d | Where-Object { $_ -like '*.ps1' } |
ForEach-Object { Get-Item -Path $_ } |
Where-Object FullName -NotMatch $PSScriptAnalyzerExclusions
$files = & git status --porcelain | Where-Object { $_ -notmatch '^D' } |
ForEach-Object { $_.TrimStart('ADMR ') } |
ForEach-Object { Get-Item -Path $_ } |
Where-Object { $_ -like '*.ps1' } |
Where-Object FullName -NotMatch $PSScriptAnalyzerExclusions
Write-Build DarkGray "Total Files to Process: $(@($Files).Count)"
$x = 0
$id = Get-Random
Write-Progress -Id $id -Activity 'Formatting Files' -PercentComplete 0
$files | ForEach-Object {
$f = $_
[string]$content = ([System.IO.File]::ReadAllText($f.FullName)).Trim()
if (-not $Content)
{
if (-not $Content) {
Write-Build DarkGray "Bypassed: $($f.Name) per empty"
continue
}
Expand Down

0 comments on commit a022cec

Please sign in to comment.