Skip to content

Commit

Permalink
Refactor download and unzip
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkTiedemann committed Aug 9, 2021
1 parent c3bfb00 commit ac1af03
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Put `dvm.cmd` into a directory in your `%path%`, e.g. `C:\bin`:

```batch
curl -Lo C:\bin\dvm.cmd https://github.com/MarkTiedemann/dvm.cmd/releases/download/0.11/dvm.cmd
curl -Lo C:\bin\dvm.cmd https://github.com/MarkTiedemann/dvm.cmd/releases/download/0.12/dvm.cmd
```

## Usage
Expand Down
32 changes: 14 additions & 18 deletions dvm.cmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@echo off
setlocal enabledelayedexpansion

set dvm_version=0.11
set dvm_version=0.12
set "dvm_script=%~f0"
set "dvm_script_dir=%~dp0"
set "dvm_root=%appdata%\dvm"
Expand Down Expand Up @@ -78,26 +78,22 @@ exit /b 0
:download
if [%2] equ [] (
for /f %%v in ('curl -s https://dl.deno.land/release-latest.txt') do (
if exist "%dvm_root%\deno-%%v.exe" (
echo Deno %%v is already downloaded
) else (
echo Downloading Deno %%v
curl -o "%dvm_root%\deno-%%v.zip" https://dl.deno.land/release/%%v/deno-x86_64-pc-windows-msvc.zip
tar xf "%dvm_root%\deno-%%v.zip" -C "%dvm_root%"
del "%dvm_root%\deno-%%v.zip"
ren "%dvm_root%\deno.exe" deno-%%v.exe
)
call :download_unzip _ %%v
)
) else (
if exist "%dvm_root%\deno-%2.exe" (
call :download_unzip _ %2
)
exit /b 0

:download_unzip
if exist "%dvm_root%\deno-%2.exe" (
echo Deno %2 is already downloaded
) else (
echo Downloading Deno %2
curl -o "%dvm_root%\deno-%2.zip" https://dl.deno.land/release/%2/deno-x86_64-pc-windows-msvc.zip
tar xf "%dvm_root%\deno-%2.zip" -C "%dvm_root%"
del "%dvm_root%\deno-%2.zip"
ren "%dvm_root%\deno.exe" deno-%2.exe
)
) else (
echo Downloading Deno %2
curl -o "%dvm_root%\deno-%2.zip" https://dl.deno.land/release/%2/deno-x86_64-pc-windows-msvc.zip
tar xf "%dvm_root%\deno-%2.zip" -C "%dvm_root%"
del "%dvm_root%\deno-%2.zip"
ren "%dvm_root%\deno.exe" deno-%2.exe
)
exit /b 0

Expand Down

0 comments on commit ac1af03

Please sign in to comment.