Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Implement `lein upgrade` for Windows #861

Merged
merged 2 commits into from

2 participants

@kumarshantanu
Collaborator

This pull request fixes #794 by implementing lein upgrade support for the Windows batch script.

Editing of the script download URL may be necessary before release.

@michaelklishin michaelklishin merged commit 9e9f431 into technomancy:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 40 additions and 9 deletions.
  1. +40 −9 bin/lein.bat
View
49 bin/lein.bat
@@ -27,7 +27,7 @@ if "x%LEIN_HOME%" == "x" (
if "x%LEIN_JAR%" == "x" set LEIN_JAR=!LEIN_HOME!\self-installs\leiningen-!LEIN_VERSION!-standalone.jar
if "%1" == "self-install" goto SELF_INSTALL
-if "%1" == "upgrade" goto NO_UPGRADE
+if "%1" == "upgrade" goto UPGRADE
if exist "%~dp0..\src\leiningen\version.clj" (
:: Running from source checkout.
@@ -148,6 +148,45 @@ if %SNAPSHOT% == YES echo See README.md for SNAPSHOT build instructions.
echo.
goto EOF
+
+:UPGRADE
+set LEIN_BAT=%~dp0%~nx0
+echo The script at %LEIN_BAT% will be upgraded to the latest version in series %LEIN_VERSION%.
+set /P ANSWER=Do you want to continue (Y/N)?
+if /i {%ANSWER%}=={y} goto YES_UPGRADE
+if /i {%ANSWER%}=={yes} goto YES_UPGRADE
+echo Aborted.
+exit /B 1
+
+
+:YES_UPGRADE
+echo Downloading latest Leiningen batch script...
+
+set HTTP_CLIENT=wget --no-check-certificate -O
+wget>nul 2>&1
+if ERRORLEVEL 9009 (
+ curl>nul 2>&1
+ if ERRORLEVEL 9009 goto NO_HTTP_CLIENT
+ set HTTP_CLIENT=curl --insecure -f -L -o
+)
+::set LEIN_BAT_URL=https://raw.github.com/technomancy/leiningen/master/bin/lein.bat
+set LEIN_BAT_URL=https://raw.github.com/technomancy/leiningen/preview/bin/lein.bat
+set TEMP_BAT=%~dp0temp-lein-%RANDOM%%RANDOM%.bat
+%HTTP_CLIENT% "%LEIN_BAT%.pending" %LEIN_BAT_URL%
+if ERRORLEVEL 1 (
+ del "%LEIN_BAT%.pending" >nul 2>&1
+ echo Failed to download %LEIN_BAT_URL%
+ goto EOF
+)
+move /y "%LEIN_BAT%.pending" "%TEMP_BAT%"
+echo.
+echo Upgrading...
+set LEIN_JAR=
+call "%TEMP_BAT%" self-install
+move /y "%TEMP_BAT%" "%LEIN_BAT%" && goto EOF
+goto EOF
+
+
:NO_HTTP_CLIENT
echo.
echo ERROR: Wget/Curl not found. Make sure at least either of Wget and Curl is
@@ -158,14 +197,6 @@ echo Curl: "http://curl.haxx.se/dlwiz/?type=bin&os=Win32&flav=-&ver=2000/XP"
echo.
goto EOF
-:NO_UPGRADE
-echo.
-echo Upgrade feature is not available on Windows. Please edit the value of
-echo variable LEIN_VERSION in file %~f0
-echo then run "lein self-install".
-echo.
-goto EOF
-
:SET_LEIN_ROOT
set LEIN_ROOT=%~f1
Something went wrong with that request. Please try again.