Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.build/build.ps1: return to working dir even after an error
When testing the script locally in PowerShell console, I noticed that if one of the commands fails and causes the termination of the script, the last command `Pop-Location` is not executed and thus the working directory in the PowerShell console remains `$repoRoot\build`. From the user's point of view, this means that the script changed their working directory, which is annoying. For example, here is how the old version of the script behaves in a PowerShell session if the `build/` folder is not writable: ``` PS C:\temp\kaitai_struct\runtime\cpp_stl> .\.build\build.ps1 -GTestPath C:\temp\vcpkg\installed\x64-windows Re-run cmake no build system arguments CMake Error: Unable to (re)create the private pkgRedirects directory: C:/temp/kaitai_struct/runtime/cpp_stl/build/CMakeFiles/pkgRedirects Exception: C:\temp\kaitai_struct\runtime\cpp_stl\.build\build.ps1:35 Line | 35 | throw "'cmake' exited with code $LastExitCode" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 'cmake' exited with code 1 PS C:\temp\kaitai_struct\runtime\cpp_stl\build> ``` Notice that the original prompt was `PS C:\temp\kaitai_struct\runtime\cpp_stl>`, but the new prompt is `PS C:\temp\kaitai_struct\runtime\cpp_stl\build>`. This commit fixes this issue by ensuring that `Pop-Location` runs regardless of whether any previous command failed.
- Loading branch information