mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-15 17:30:37 -06:00
Move Preprocessing to a separate script file
This commit is contained in:
parent
1ed15a4040
commit
a57c6a8b40
36
Compile.ps1
36
Compile.ps1
@ -28,40 +28,6 @@ function Update-Progress {
|
|||||||
Write-Progress -Activity $Activity -Status $StatusMessage -PercentComplete $Percent
|
Write-Progress -Activity $Activity -Status $StatusMessage -PercentComplete $Percent
|
||||||
}
|
}
|
||||||
|
|
||||||
function Do-PreProcessing {
|
|
||||||
param (
|
|
||||||
[Parameter(Mandatory, position=0)]
|
|
||||||
[string]$ProgressStatusMessage,
|
|
||||||
|
|
||||||
[Parameter(position=1)]
|
|
||||||
[string]$ProgressActivity = "Pre-Processing"
|
|
||||||
)
|
|
||||||
|
|
||||||
$excludedFiles = @('git\', '.gitignore', '.gitattributes', '.github\CODEOWNERS', 'LICENSE', 'winutil.ps1', 'docs\changelog.md', '*.png', '*.jpg', '*.jpeg', '*.exe')
|
|
||||||
|
|
||||||
$files = Get-ChildItem $workingdir -Recurse -Exclude $excludedFiles -Attributes !Directory
|
|
||||||
$numOfFiles = $files.Count
|
|
||||||
|
|
||||||
for ($i = 0; $i -lt $numOfFiles; $i++) {
|
|
||||||
$file = $files[$i]
|
|
||||||
# TODO:
|
|
||||||
# make more formatting rules, and document them in WinUtil Official Documentation
|
|
||||||
(Get-Content -Raw "$file").TrimEnd() `
|
|
||||||
-replace ('\t', ' ') `
|
|
||||||
-replace ('\)\{', ') {') `
|
|
||||||
-replace ('\)\r?\n\s*{', ') {') `
|
|
||||||
-replace ('Try \{', 'try {') `
|
|
||||||
-replace ('try\{', 'try {') `
|
|
||||||
-replace ('try\r?\n\s*\{', 'try {') `
|
|
||||||
-replace ('}\r?\n\s*catch', '} catch') `
|
|
||||||
-replace ('\} Catch', '} catch') `
|
|
||||||
| Set-Content "$file"
|
|
||||||
Write-Progress -Activity $ProgressActivity -Status "$ProgressStatusMessage - Finished $i out of $numOfFiles" -PercentComplete (($i/$numOfFiles)*100)
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Progress -Activity $ProgressActivity -Status "$ProgressStatusMessage - Finished Task Successfully" -Completed
|
|
||||||
}
|
|
||||||
|
|
||||||
$header = @"
|
$header = @"
|
||||||
################################################################################################################
|
################################################################################################################
|
||||||
### ###
|
### ###
|
||||||
@ -71,6 +37,8 @@ $header = @"
|
|||||||
"@
|
"@
|
||||||
|
|
||||||
if (-NOT $SkipPreprocessing) {
|
if (-NOT $SkipPreprocessing) {
|
||||||
|
# Dot source the 'Do-PreProcessing' Function from 'tools/Do-PreProcessing.ps1' Function
|
||||||
|
. "$workingdir\tools\Do-PreProcessing.ps1"
|
||||||
$msg = "Pre-req: Code Formatting"
|
$msg = "Pre-req: Code Formatting"
|
||||||
Update-Progress "Pre-req: Allocating Memory" 0
|
Update-Progress "Pre-req: Allocating Memory" 0
|
||||||
Do-PreProcessing $msg
|
Do-PreProcessing $msg
|
||||||
|
33
tools/Do-PreProcessing.ps1
Normal file
33
tools/Do-PreProcessing.ps1
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
function Do-PreProcessing {
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory, position=0)]
|
||||||
|
[string]$ProgressStatusMessage,
|
||||||
|
|
||||||
|
[Parameter(position=1)]
|
||||||
|
[string]$ProgressActivity = "Pre-Processing"
|
||||||
|
)
|
||||||
|
|
||||||
|
$excludedFiles = @('git\', '.gitignore', '.gitattributes', '.github\CODEOWNERS', 'LICENSE', 'winutil.ps1', 'docs\changelog.md', '*.png', '*.jpg', '*.jpeg', '*.exe')
|
||||||
|
|
||||||
|
$files = Get-ChildItem $workingdir -Recurse -Exclude $excludedFiles -Attributes !Directory
|
||||||
|
$numOfFiles = $files.Count
|
||||||
|
|
||||||
|
for ($i = 0; $i -lt $numOfFiles; $i++) {
|
||||||
|
$file = $files[$i]
|
||||||
|
# TODO:
|
||||||
|
# make more formatting rules, and document them in WinUtil Official Documentation
|
||||||
|
(Get-Content -Raw "$file").TrimEnd() `
|
||||||
|
-replace ('\t', ' ') `
|
||||||
|
-replace ('\)\{', ') {') `
|
||||||
|
-replace ('\)\r?\n\s*{', ') {') `
|
||||||
|
-replace ('Try \{', 'try {') `
|
||||||
|
-replace ('try\{', 'try {') `
|
||||||
|
-replace ('try\r?\n\s*\{', 'try {') `
|
||||||
|
-replace ('}\r?\n\s*catch', '} catch') `
|
||||||
|
-replace ('\} catch', '} catch') `
|
||||||
|
| Set-Content "$file"
|
||||||
|
Write-Progress -Activity $ProgressActivity -Status "$ProgressStatusMessage - Finished $i out of $numOfFiles" -PercentComplete (($i/$numOfFiles)*100)
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Progress -Activity $ProgressActivity -Status "$ProgressStatusMessage - Finished Task Successfully" -Completed
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user