setup-clink64.bat 1.27 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
@echo off

WHERE unzip
IF %ERRORLEVEL% NEQ 0 (
	echo Cywin with unzip required
	goto end
)

rem we check de powershell version if lower that 3 exit
for /f %%i in ('powershell -Command "$PSVersionTable.PSVersion.Major"') do set powershellVersion=%%i
echo powershellVersion=%powershellVersion%

if %powershellVersion% LSS 3 (
  echo Only works with powershell greater or equal to 3 
  goto end
)

IF "%CLINK_VERSION%" == "" (
set CLINK_VERSION=0.4.9
echo Defaults CLINK_VERSION=%CLINK_VERSION%
)

echo "downloading click"

set downloadUrl="https://github.com/mridgers/clink/releases/download/%CLINK_VERSION%/clink_%CLINK_VERSION%.zip"

mkdir downloads 2> nul

for /f %%i in ('powershell -Command "$(split-path -path %downloadUrl% -leaf)"') do set appFileName=%%i
echo appFileName=%appFileName%

if Not exist "downloads\%appFileName%" (
    rem file exists
	echo downloading %downloadUrl% to downloads
	rem we escape because we are inside if
	powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest %downloadUrl% -OutFile downloads\%appFileName%"
)

rem we install app
set APP_HOME_REL_PATH=clink64
mkdir %APP_HOME_REL_PATH% 2> nul

unzip -j downloads\%appFileName% -d %APP_HOME_REL_PATH%

:end