Created
October 9, 2019 13:17
-
-
Save safizn/167319cb33c25e96194d12554349a031 to your computer and use it in GitHub Desktop.
Powershell - compare commandline path to current executed script path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Must be executed from the root path of the git repository. | |
$commandlineCurrentPath = pwd # Get-Location equivalent | |
$currentExecutedScriptPath = $PSScriptRoot | |
$parentOfCurrentExecutedScriptPath = Split-Path -Path $currentExecutedScriptPath -Parent | |
if(-Not ($parentOfCurrentExecutedScriptPath -eq $commandlineCurrentPath) ){ | |
$message = "Error ! This script must be executed from the root path of the git repository, as it needs to verify path of WSL scripst executed from it." | |
Write-Host $message -ForegroundColor Red -BackgroundColor Black | |
pause | |
break | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment