I have a deployment script that should work on windows and linux.
I need to delete a directory if it exists. The cmd command on windows is:
if exist BackendFrontendShare rmdir somedir /s /q
Is there some way to write a command that supports both platforms?
I tried
rm -rf somedir || if exist somedir rmdir somedir /s /q
which works on windows, but not on linux
PowerShell runs on Linux, Mac, and Windows. The same code works on all platforms. https://github.com/PowerShell/PowerShell
Use the
-WhatIfswitch to find out what would be done if the items were removed.