mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-15 17:30:37 -06:00
Patched a Bug of some Excluded Files not actually get excluded in 'Get-ChildItem' PS Cmdlet
This commit is contained in:
parent
2732b271ef
commit
177bbc752b
@ -9,13 +9,33 @@ function Do-PreProcessing {
|
||||
|
||||
# We could do Pre-processing on this script file, but by excluding it.. we could possible weird behavior,
|
||||
# like future runs of this tool being different then previous ones, as the script has modified it self before one or more times.
|
||||
$excludedFiles = @('git\', '.gitignore', '.gitattributes', '.github\CODEOWNERS', 'LICENSE', 'winutil.ps1', 'tools\Do-PreProcessing.ps1', 'docs\changelog.md', '*.png', '*.jpg', '*.jpeg', '*.exe')
|
||||
#
|
||||
# Note:
|
||||
# There's way too many possible edge cases, not to mention there's no Unit Testing for these tools.. which's a Good Recipe for a Janky/Sensitive Script.
|
||||
# Also, the '.\' isn't necessary, I just like adding them :D (You can remove it, and it should work just fine)
|
||||
$excludedFiles = @('.\.git\', '.\.gitignore', '.\.gitattributes', '.\.github\CODEOWNERS', '.\LICENSE', '.\winutil.ps1', '.\tools\Do-PreProcessing.ps1', '.\docs\changelog.md', '*.png', '*.jpg', '*.jpeg', '*.exe')
|
||||
|
||||
$files = Get-ChildItem $sync.PSScriptRoot -Recurse -Exclude $excludedFiles -Attributes !Directory
|
||||
$numOfFiles = $files.Count
|
||||
|
||||
for ($i = 0; $i -lt $numOfFiles; $i++) {
|
||||
$file = $files[$i]
|
||||
|
||||
# Make sure the file isn't in Excluded Files List
|
||||
$fileIsExcluded = $False
|
||||
for ($j = 0; $j -lt $excludedFiles.Count; $j++) {
|
||||
$excluded = $excludedFiles[$j]
|
||||
$strToCompare = ($excluded) -replace ('^\.\\', '')
|
||||
if ($file.FullName.Contains("$strToCompare")) {
|
||||
$fileIsExcluded = $True
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if ($fileIsExcluded) {
|
||||
continue
|
||||
}
|
||||
|
||||
# TODO:
|
||||
# make more formatting rules, and document them in WinUtil Official Documentation
|
||||
(Get-Content -Raw "$file").TrimEnd() `
|
||||
|
Loading…
Reference in New Issue
Block a user