Make Preprocessing more advanced

This commit is contained in:
Mr.k 2024-07-26 05:27:19 +03:00
parent b5dffd671f
commit 1ed15a4040
No known key found for this signature in database

View File

@ -44,7 +44,18 @@ function Do-PreProcessing {
for ($i = 0; $i -lt $numOfFiles; $i++) {
$file = $files[$i]
(Get-Content "$file").TrimEnd() | Set-Content "$file"
# 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)
}
@ -165,8 +176,7 @@ Write-Progress -Activity "Compiling" -Completed
if ($run) {
try {
Start-Process -FilePath "pwsh" -ArgumentList "$workingdir\$scriptname"
}
catch {
} catch {
Start-Process -FilePath "powershell" -ArgumentList "$workingdir\$scriptname"
}