Skip to content

Commit e36021f

Browse files
committed
Improved check for $lastExitCode
1 parent c6929fc commit e36021f

File tree

91 files changed

+204
-204
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+204
-204
lines changed

scripts/build-repo.ps1

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,99 +29,99 @@ function BuildInDir([string]$path) {
2929

3030
"⏳ (2/4) Executing 'cmake' to generate the Makefile..."
3131
& cmake ..
32-
if ($lastExitCode -ne "0") { throw "Executing 'cmake ..' exited with error code $lastExitCode" }
32+
if ($lastExitCode -ne 0) { throw "Executing 'cmake ..' exited with error code $lastExitCode" }
3333

3434
"⏳ (3/4) Executing 'make -j4' to compile and link..."
3535
& make -j4
36-
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' exited with error code $lastExitCode" }
36+
if ($lastExitCode -ne 0) { throw "Executing 'make -j4' exited with error code $lastExitCode" }
3737

3838
"⏳ (4/4) Executing 'ctest -V' to perform tests (optional)..."
3939
& ctest -V
40-
if ($lastExitCode -ne "0") { throw "Executing 'ctest -V' exited with error code $lastExitCode" }
40+
if ($lastExitCode -ne 0) { throw "Executing 'ctest -V' exited with error code $lastExitCode" }
4141

4242
} elseif (Test-Path "$path/autogen.sh" -pathType leaf) {
4343
"⏳ Building 📂$dirName by using 'autogen.sh'..."
4444
Set-Location "$path/"
4545

4646
& ./autogen.sh --force
47-
if ($lastExitCode -ne "0") { throw "Executing './autogen.sh --force' exited with error code $lastExitCode" }
47+
if ($lastExitCode -ne 0) { throw "Executing './autogen.sh --force' exited with error code $lastExitCode" }
4848

4949
& ./configure
50-
if ($lastExitCode -ne "0") { throw "Executing './configure' exited with error code $lastExitCode" }
50+
if ($lastExitCode -ne 0) { throw "Executing './configure' exited with error code $lastExitCode" }
5151

5252
& make -j4
53-
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' exited with error code $lastExitCode" }
53+
if ($lastExitCode -ne 0) { throw "Executing 'make -j4' exited with error code $lastExitCode" }
5454

5555

5656
} elseif (Test-Path "$path/configure" -pathType leaf) {
5757
"⏳ Building 📂$dirName by using 'configure'..."
5858
Set-Location "$path/"
5959

6060
& ./configure
61-
#if ($lastExitCode -ne "0") { throw "Executing './configure' exited with error code $lastExitCode" }
61+
#if ($lastExitCode -ne 0) { throw "Executing './configure' exited with error code $lastExitCode" }
6262

6363
& make -j4
64-
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
64+
if ($lastExitCode -ne 0) { throw "Executing 'make -j4' has failed" }
6565

6666
& make test
67-
if ($lastExitCode -ne "0") { throw "Executing 'make test' has failed" }
67+
if ($lastExitCode -ne 0) { throw "Executing 'make test' has failed" }
6868

6969
} elseif (Test-Path "$path/build.gradle" -pathType leaf) {
7070
"⏳ Building 📂$dirName by using Gradle..."
7171
Set-Location "$path"
7272

7373
& gradle build
74-
if ($lastExitCode -ne "0") { throw "Executing 'gradle build' exited with error code $lastExitCode" }
74+
if ($lastExitCode -ne 0) { throw "Executing 'gradle build' exited with error code $lastExitCode" }
7575

7676
& gradle test
77-
if ($lastExitCode -ne "0") { throw "Executing 'gradle test' exited with error code $lastExitCode" }
77+
if ($lastExitCode -ne 0) { throw "Executing 'gradle test' exited with error code $lastExitCode" }
7878

7979
} elseif (Test-Path "$path/meson.build" -pathType leaf) {
8080
"⏳ Building 📂$dirName by using Meson..."
8181
Set-Location "$path"
8282
& meson . build --prefix=/usr/local
83-
if ($lastExitCode -ne "0") { throw "Executing 'meson . build' exited with error code $lastExitCode" }
83+
if ($lastExitCode -ne 0) { throw "Executing 'meson . build' exited with error code $lastExitCode" }
8484

8585
} elseif (Test-Path "$path/Imakefile" -pathType leaf) {
8686
"⏳ Building 📂$dirName by using Imakefile..."
8787
Set-Location "$path/"
8888

8989
& xmkmf
90-
if ($lastExitCode -ne "0") { throw "Executing 'xmkmf' has failed" }
90+
if ($lastExitCode -ne 0) { throw "Executing 'xmkmf' has failed" }
9191

9292
& make -j4
93-
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
93+
if ($lastExitCode -ne 0) { throw "Executing 'make -j4' has failed" }
9494

9595
} elseif (Test-Path "$path/Makefile" -pathType leaf) {
9696
"⏳ Building 📂$dirName by using Makefile..."
9797
Set-Location "$path"
9898

9999
& make -j4
100-
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
100+
if ($lastExitCode -ne 0) { throw "Executing 'make -j4' has failed" }
101101

102102
} elseif (Test-Path "$path/makefile" -pathType leaf) {
103103
"⏳ Building 📂$dirName by using makefile..."
104104
Set-Location "$path"
105105

106106
& make -j4
107-
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
107+
if ($lastExitCode -ne 0) { throw "Executing 'make -j4' has failed" }
108108

109109
} elseif (Test-Path "$path/compile.sh" -pathType leaf) {
110110
"⏳ Building 📂$dirName by using 'compile.sh'..."
111111
Set-Location "$path/"
112112

113113
& ./compile.sh
114-
if ($lastExitCode -ne "0") { throw "Executing './compile.sh' exited with error code $lastExitCode" }
114+
if ($lastExitCode -ne 0) { throw "Executing './compile.sh' exited with error code $lastExitCode" }
115115

116116
& make -j4
117-
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
117+
if ($lastExitCode -ne 0) { throw "Executing 'make -j4' has failed" }
118118

119119
} elseif (Test-Path "$path/attower/src/build/DevBuild/build.bat" -pathType leaf) {
120120
"⏳ Building 📂$dirName by using build.bat ..."
121121
Set-Location "$path/attower/src/build/DevBuild/"
122122

123123
& ./build.bat build-all-release
124-
if ($lastExitCode -ne "0") { throw "Executing 'build.bat build-all-release' exited with error code $lastExitCode" }
124+
if ($lastExitCode -ne 0) { throw "Executing 'build.bat build-all-release' exited with error code $lastExitCode" }
125125

126126
} elseif (Test-Path "$path/$dirName" -pathType container) {
127127
"⏳ No make rule found, trying subfolder 📂$($dirName)..."

scripts/change-wallpaper.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ try {
2727

2828
$Path = "$(GetTempDir)/next_wallpaper.jpg"
2929
& wget -O $Path "https://source.unsplash.com/3840x2160?$Category"
30-
if ($lastExitCode -ne "0") { throw "Download failed" }
30+
if ($lastExitCode -ne 0) { throw "Download failed" }
3131

3232
& "$PSScriptRoot/set-wallpaper.ps1" -ImageFile "$Path"
3333
exit 0 # success

scripts/check-repo.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ try {
2828

2929
Write-Host "⏳ (1/10) Searching for Git executable... " -noNewline
3030
& git --version
31-
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
31+
if ($lastExitCode -ne 0) { throw "Can't execute 'git' - make sure Git is installed and available" }
3232

3333
Write-Host "⏳ (2/10) Checking local repository... " -noNewline
3434
$FullPath = Resolve-Path "$pathToRepo"
@@ -37,15 +37,15 @@ try {
3737

3838
Write-Host "⏳ (3/10) Querying remote URL... " -noNewline
3939
& git -C "$FullPath" remote get-url origin
40-
if ($lastExitCode -ne "0") { throw "'git remote get-url origin' failed with exit code $lastExitCode" }
40+
if ($lastExitCode -ne 0) { throw "'git remote get-url origin' failed with exit code $lastExitCode" }
4141

4242
Write-Host "⏳ (4/10) Querying current branch... " -noNewline
4343
& git -C "$FullPath" branch --show-current
44-
if ($lastExitCode -ne "0") { throw "'git branch --show-current' failed with exit code $lastExitCode" }
44+
if ($lastExitCode -ne 0) { throw "'git branch --show-current' failed with exit code $lastExitCode" }
4545

4646
Write-Host "⏳ (5/10) Fetching remote updates... " -noNewline
4747
& git -C "$FullPath" fetch --all --recurse-submodules --tags --force --quiet
48-
if ($lastExitCode -ne "0") { throw "'git fetch' failed with exit code $lastExitCode" }
48+
if ($lastExitCode -ne 0) { throw "'git fetch' failed with exit code $lastExitCode" }
4949
Write-Host "OK"
5050

5151
Write-Host "⏳ (6/10) Querying latest tag... " -noNewline
@@ -55,19 +55,19 @@ try {
5555

5656
Write-Host "⏳ (7/10) Verifying data integrity..."
5757
& git -C "$FullPath" fsck
58-
if ($lastExitCode -ne "0") { throw "'git fsck' failed with exit code $lastExitCode" }
58+
if ($lastExitCode -ne 0) { throw "'git fsck' failed with exit code $lastExitCode" }
5959

6060
Write-Host "⏳ (8/10) Running maintenance tasks..."
6161
& git -C "$FullPath" maintenance run
62-
if ($lastExitCode -ne "0") { throw "'git maintenance run' failed with exit code $lastExitCode" }
62+
if ($lastExitCode -ne 0) { throw "'git maintenance run' failed with exit code $lastExitCode" }
6363

6464
Write-Host "⏳ (9/10) Checking submodule status..."
6565
& git -C "$FullPath" submodule status
66-
if ($lastExitCode -ne "0") { throw "'git submodule status' failed with exit code $lastExitCode" }
66+
if ($lastExitCode -ne 0) { throw "'git submodule status' failed with exit code $lastExitCode" }
6767

6868
Write-Host "⏳ (10/10) Checking repo status... " -noNewline
6969
& git -C "$FullPath" status
70-
if ($lastExitCode -ne "0") { throw "'git status --short' failed with exit code $lastExitCode" }
70+
if ($lastExitCode -ne 0) { throw "'git status --short' failed with exit code $lastExitCode" }
7171

7272
$repoDirName = (Get-Item "$FullPath").Name
7373
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds

scripts/check-smart-devices.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function Bytes2String([int64]$bytes) {
3030

3131
try {
3232
$result = (smartctl --version)
33-
if ($lastExitCode -ne "0") { throw "Can't execute 'smartctl' - make sure smartmontools are installed" }
33+
if ($lastExitCode -ne 0) { throw "Can't execute 'smartctl' - make sure smartmontools are installed" }
3434

3535
if ($IsLinux) {
3636
$devices = $(sudo smartctl --scan-open)

scripts/check-windows-system-files.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
try {
1818
sfc /verifyOnly
19-
if ($lastExitCode -ne "0") { throw "'sfc /verifyOnly' failed" }
19+
if ($lastExitCode -ne 0) { throw "'sfc /verifyOnly' failed" }
2020

2121
"✅ checked Windows system files"
2222
exit 0 # success

scripts/clean-repo.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,23 @@ try {
2626

2727
Write-Host "⏳ (1/4) Searching for Git executable... " -noNewline
2828
& git --version
29-
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
29+
if ($lastExitCode -ne 0) { throw "Can't execute 'git' - make sure Git is installed and available" }
3030

3131
"⏳ (2/4) Checking local repository... $path"
3232
if (-not(Test-Path "$path" -pathType container)) { throw "Can't access repo folder '$path' - maybe a typo or missing folder permissions?" }
3333
$repoName = (Get-Item "$path").Name
3434

3535
"⏳ (3/4) Removing untracked files in repository..."
3636
& git -C "$path" clean -xfd -f # to delete all untracked files in the main repo
37-
if ($lastExitCode -ne "0") {
37+
if ($lastExitCode -ne 0) {
3838
Write-Warning "'git clean' failed with exit code $lastExitCode, retrying once..."
3939
& git -C "$path" clean -xfd -f
40-
if ($lastExitCode -ne "0") { throw "'git clean' failed with exit code $lastExitCode" }
40+
if ($lastExitCode -ne 0) { throw "'git clean' failed with exit code $lastExitCode" }
4141
}
4242

4343
"⏳ (4/4) Removing untracked files in submodules..."
4444
& git -C "$path" submodule foreach --recursive git clean -xfd -f # to delete all untracked files in the submodules
45-
if ($lastExitCode -ne "0") { throw "'git clean' in the submodules failed with exit code $lastExitCode" }
45+
if ($lastExitCode -ne 0) { throw "'git clean' in the submodules failed with exit code $lastExitCode" }
4646

4747
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
4848
"✅ Cleaned the 📂$repoName repository in $($elapsed)s."

scripts/clean-repos.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ try {
2424

2525
Write-Host "⏳ (1) Searching for Git executable... " -noNewline
2626
& git --version
27-
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
27+
if ($lastExitCode -ne 0) { throw "Can't execute 'git' - make sure Git is installed and available" }
2828

2929
$parentDirName = (Get-Item "$ParentDir").Name
3030
Write-Host "⏳ (2) Checking parent folder 📂$parentDirName... " -noNewline
@@ -40,10 +40,10 @@ try {
4040
"⏳ ($Step/$($numFolders + 2)) Cleaning 📂$FolderName..."
4141

4242
& git -C "$folder" clean -xfd -f # force + recurse into dirs + don't use the standard ignore rules
43-
if ($lastExitCode -ne "0") { throw "'git clean -xfd -f' failed with exit code $lastExitCode" }
43+
if ($lastExitCode -ne 0) { throw "'git clean -xfd -f' failed with exit code $lastExitCode" }
4444

4545
& git -C "$folder" submodule foreach --recursive git clean -xfd -f
46-
if ($lastExitCode -ne "0") { throw "'git clean -xfd -f' in submodules failed with exit code $lastExitCode" }
46+
if ($lastExitCode -ne 0) { throw "'git clean -xfd -f' in submodules failed with exit code $lastExitCode" }
4747
}
4848
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
4949
"✅ Cleaned $numFolders Git repositories under 📂$parentDirName in $($elapsed)s."

scripts/clear-recycle-bin.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
try {
1616
Clear-RecycleBin -Confirm:$false
17-
if ($lastExitCode -ne "0") { throw "'Clear-RecycleBin' failed" }
17+
if ($lastExitCode -ne 0) { throw "'Clear-RecycleBin' failed" }
1818

1919
& "$PSScriptRoot/speak-english.ps1" "It's clean now."
2020
exit 0 # success

scripts/clone-repos.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ try {
2525

2626
Write-Host "⏳ (1) Searching for Git executable... " -noNewline
2727
& git --version
28-
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
28+
if ($lastExitCode -ne 0) { throw "Can't execute 'git' - make sure Git is installed and available" }
2929

3030
Write-Host "⏳ (2) Reading data/popular-repos.csv... " -noNewline
3131
$table = Import-CSV "$PSScriptRoot/../data/popular-repos.csv"
@@ -53,12 +53,12 @@ try {
5353
} elseif ($shallow -eq "yes") {
5454
"⏳ ($step/$($total + 3)) Cloning 📂$folderName ($category) from $URL ($branch branch only)..."
5555
& git clone --branch "$branch" --single-branch --recurse-submodules "$URL" "$targetDir/$folderName"
56-
if ($lastExitCode -ne "0") { throw "'git clone --branch $branch $URL' failed with exit code $lastExitCode" }
56+
if ($lastExitCode -ne 0) { throw "'git clone --branch $branch $URL' failed with exit code $lastExitCode" }
5757
$cloned++
5858
} else {
5959
"⏳ ($step/$($total + 3)) Cloning 📂$folderName ($category) from $URL (full $branch branch)..."
6060
& git clone --branch "$branch" --recurse-submodules "$URL" "$targetDir/$folderName"
61-
if ($lastExitCode -ne "0") { throw "'git clone --branch $branch $URL' failed with exit code $lastExitCode" }
61+
if ($lastExitCode -ne 0) { throw "'git clone --branch $branch $URL' failed with exit code $lastExitCode" }
6262
$clone++
6363
}
6464
}

scripts/close-edge.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#>
1313

1414
TaskKill /im msedge.exe /f /t
15-
if ($lastExitCode -ne "0") {
15+
if ($lastExitCode -ne 0) {
1616
& "$PSScriptRoot/speak-english.ps1" "Sorry, Microsoft Edge isn't running."
1717
exit 1
1818
}

scripts/close-git-extensions.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#>
1313

1414
TaskKill /im GitExtensions.exe
15-
if ($lastExitCode -ne "0") {
15+
if ($lastExitCode -ne 0) {
1616
& "$PSScriptRoot/speak-english.ps1" "Sorry, Git Extensions isn't running."
1717
exit 1
1818
}

scripts/close-microsoft-paint.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#>
1313

1414
TaskKill /im mspaint.exe
15-
if ($lastExitCode -ne "0") {
15+
if ($lastExitCode -ne 0) {
1616
& "$PSScriptRoot/speak-english.ps1" "Sorry, Microsoft Paint isn't running."
1717
exit 1
1818
}

scripts/close-microsoft-store.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#>
1313

1414
TaskKill /im WinStore.App.exe /f /t
15-
if ($lastExitCode -ne "0") {
15+
if ($lastExitCode -ne 0) {
1616
& "$PSScriptRoot/speak-english.ps1" "Sorry, Microsoft Store isn't running."
1717
exit 1
1818
}

scripts/close-obs-studio.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#>
1313

1414
TaskKill /im obs64.exe
15-
if ($lastExitCode -ne "0") {
15+
if ($lastExitCode -ne 0) {
1616
& "$PSScriptRoot/speak-english.ps1" "Sorry, OBS Studio isn't running"
1717
exit 1
1818
}

scripts/close-one-calendar.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#>
1313

1414
TaskKill /f /im CalendarApp.Gui.Win10.exe
15-
if ($lastExitCode -ne "0") {
15+
if ($lastExitCode -ne 0) {
1616
& "$PSScriptRoot/speak-english.ps1" "Sorry, OneCalendar isn't running."
1717
exit 1
1818
}

scripts/close-outlook.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#>
1313

1414
TaskKill /im outlook.exe
15-
if ($lastExitCode -ne "0") {
15+
if ($lastExitCode -ne 0) {
1616
& "$PSScriptRoot/speak-english.ps1" "Sorry, Microsoft Outlook isn't running."
1717
exit 1
1818
}

scripts/close-paint-three-d.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#>
1313

1414
TaskKill /im PaintStudio.View.exe /f
15-
if ($lastExitCode -ne "0") {
15+
if ($lastExitCode -ne 0) {
1616
& "$PSScriptRoot/speak-english.ps1" "Sorry, Paint 3D isn't running."
1717
exit 1
1818
}

scripts/close-three-d-viewer.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#>
1313

1414
TaskKill /im 3DViewer.exe /f
15-
if ($lastExitCode -ne "0") {
15+
if ($lastExitCode -ne 0) {
1616
& "$PSScriptRoot/speak-english.ps1" "Sorry, 3D Viewer isn't running."
1717
exit 1
1818
}

scripts/close-thunderbird.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#>
1313

1414
TaskKill /im thunderbird.exe
15-
if ($lastExitCode -ne "0") {
15+
if ($lastExitCode -ne 0) {
1616
& "$PSScriptRoot/speak-english.ps1" "Sorry, Mozilla Thunderbird isn't running."
1717
exit 1
1818
}

scripts/close-visual-studio.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#>
1313

1414
TaskKill /im devenv.exe
15-
if ($lastExitCode -ne "0") {
15+
if ($lastExitCode -ne 0) {
1616
& "$PSScriptRoot/speak-english.ps1" "Sorry, Visual Studio isn't running."
1717
exit 1
1818
}

0 commit comments

Comments
 (0)