Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows port #2

Merged
merged 1 commit into from
Mar 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions millw.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
@echo off

rem This is a wrapper script, that automatically download mill from GitHub release pages
rem You can give the required mill version with --mill-version parameter
rem If no version is given, it falls back to the value of DEFAULT_MILL_VERSION

rem setlocal seems to be unavailable on Windows 95/98/ME
rem but I don't think we need to support them in 2019
setlocal enabledelayedexpansion

set DEFAULT_MILL_VERSION=0.3.6

if exist .mill-version (
set /p MILL_VERSION= < .mill-version
)

rem %~1% removes surrounding quotes
if "%~1%"=="--mill-version" (
rem shift command doesn't work within parentheses
if not "%~2%"=="" (
set MILL_VERSION=%~2%
) else (
echo You specified --mill-version without a version.
echo Please provide a version that matches one provided on
echo https://github.com/lihaoyi/mill/releases
exit /b 1
)
)

if "%MILL_VERSION%"=="" (
set MILL_VERSION=%DEFAULT_MILL_VERSION%
)

set MILL_DOWNLOAD_PATH=%USERPROFILE%\.mill\download

rem without bat file extension, cmd doesn't seem to be able to run it
set MILL=%MILL_DOWNLOAD_PATH%\%MILL_VERSION%.bat

if not exist "%MILL%" (
rem there seems to be no way to generate a unique temporary file path (on native Windows)
set DOWNLOAD_FILE=%MILL%.tmp

rem curl is bundled with recent Windows 10
rem but I don't think we can expect all the users to have it in 2019
rem bitadmin seems to be available on Windows 7
rem without /dynamic, github returns 403
rem bitadmin is sometimes needlessly slow but it looks better with /priority foreground
if not exist "%MILL_DOWNLOAD_PATH%" mkdir "%MILL_DOWNLOAD_PATH%"
bitsadmin /transfer millDownloadJob /dynamic /priority foreground "https://github.com/lihaoyi/mill/releases/download/%MILL_VERSION%/%MILL_VERSION%" "!DOWNLOAD_FILE!"

move /y "!DOWNLOAD_FILE!" "%MILL%"
set DOWNLOAD_FILE=
)

set MILL_DOWNLOAD_PATH=
set MILL_VERSION=

%MILL% %*