Compare commits

..

No commits in common. "895a95ccf67bf9e853d9019317b101c99439c709" and "07e154459de7083171aa7f08973ff9afdf70ab0c" have entirely different histories.

2 changed files with 12 additions and 20 deletions

View File

@ -46,7 +46,7 @@ if (-NOT $SkipPreprocessing) {
$preprocessingFilePath = ".\tools\Invoke-Preprocessing.ps1" $preprocessingFilePath = ".\tools\Invoke-Preprocessing.ps1"
. $preprocessingFilePath . $preprocessingFilePath
$excludedFiles = @('.\.git\', '.\.gitignore', '.\.gitattributes', '.\.github\CODEOWNERS', '.\.github\LICENSE', "$preprocessingFilePath", '*.png', '*.exe') $excludedFiles = @('.\.git\', '.\.gitignore', '.\.gitattributes', '.\.github\CODEOWNERS', '.\LICENSE', "$preprocessingFilePath", '*.png', '*.exe')
$msg = "Pre-req: Code Formatting" $msg = "Pre-req: Code Formatting"
Invoke-Preprocessing -WorkingDir "$workingdir" -ExcludedFiles $excludedFiles -ProgressStatusMessage $msg -ThrowExceptionOnEmptyFilesList Invoke-Preprocessing -WorkingDir "$workingdir" -ExcludedFiles $excludedFiles -ProgressStatusMessage $msg -ThrowExceptionOnEmptyFilesList
} }

View File

@ -47,7 +47,7 @@
Same as Example No. 1, but uses '-SkipExcludedFilesValidation', which'll skip the validation step for 'ExcludedFiles' list. This can be useful when 'ExcludedFiles' list is generated from another function, or from unreliable source (you can't guarantee every item in list is a valid path), but you want to silently continue through the function. Same as Example No. 1, but uses '-SkipExcludedFilesValidation', which'll skip the validation step for 'ExcludedFiles' list. This can be useful when 'ExcludedFiles' list is generated from another function, or from unreliable source (you can't guarantee every item in list is a valid path), but you want to silently continue through the function.
#> #>
param ( param (
[Parameter(position=0)] [Parameter(position=0)]
[switch]$SkipExcludedFilesValidation, [switch]$SkipExcludedFilesValidation,
@ -66,7 +66,7 @@
[Parameter(position=5)] [Parameter(position=5)]
[string]$ProgressActivity = "Preprocessing" [string]$ProgressActivity = "Preprocessing"
) )
if (-NOT (Test-Path -PathType Container -Path "$WorkingDir")) { if (-NOT (Test-Path -PathType Container -Path "$WorkingDir")) {
throw "[Invoke-Preprocessing] Invalid Paramter Value for 'WorkingDir', passed value: '$WorkingDir'. Either the path is a File or Non-Existing/Invlid, please double check your code." throw "[Invoke-Preprocessing] Invalid Paramter Value for 'WorkingDir', passed value: '$WorkingDir'. Either the path is a File or Non-Existing/Invlid, please double check your code."
@ -75,30 +75,22 @@
$count = $ExcludedFiles.Count $count = $ExcludedFiles.Count
# Make sure there's a * at the end of folders in ExcludedFiles list # Make sure there's a * at the end of folders in ExcludedFiles list
for ($i = 0; $i -lt $count; $i++) { if ($count -gt 0) {
$excludedFile = $ExcludedFiles[$i] for ($i = 0; $i -lt $count; $i++) {
$isFolder = ($excludedFile) -match '\\$' $excludedFile = $ExcludedFiles[$i]
if ($isFolder) { $ExcludedFiles[$i] = $excludedFile + '*' } $isFolder = ($excludedFile) -match '\\$'
if ($isFolder) { $ExcludedFiles[$i] = $excludedFile + '*' }
}
} }
# Validate the ExcludedFiles List before continuing on, # Validate the ExcludedFiles List before continuing on,
# that's if there's a list in the first place, and '-SkipExcludedFilesValidation' was not provided. # that's if there's a list in the first place, and '-SkipExcludedFilesValidation' was not provided.
if (-not $SkipExcludedFilesValidation) { if ((-NOT ($count -eq 0)) -AND (-NOT $SkipExcludedFilesValidation)) {
for ($i = 0; $i -lt $count; $i++) { for ($i = 0; $i -lt $count; $i++) {
$excludedFile = $ExcludedFiles[$i] $excludedFile = $ExcludedFiles[$i]
$filePath = "$(($WorkingDir -replace ('\\$', '')) + '\' + ($excludedFile -replace ('\.\\', '')))" $filePath = "$(($WorkingDir -replace ('\\$', '')) + '\' + ($excludedFile -replace ('\.\\', '')))"
if (-NOT (Get-ChildItem -Recurse -Path "$filePath" -File)) {
# Handle paths with wildcards in a different implementation $failedFilesList += "'$filePath', "
$matches = ($filePath) -match '^.*?\*'
if ($matches) {
if (-NOT (Get-ChildItem -Recurse -Path "$filePath" -File)) {
$failedFilesList += "'$filePath', "
}
} else {
if (-NOT (Test-Path -Path "$filePath")) {
$failedFilesList += "'$filePath', "
}
} }
} }
$failedFilesList = $failedFilesList -replace (',\s*$', '') $failedFilesList = $failedFilesList -replace (',\s*$', '')