forked from smithy-lang/smithy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.bat
More file actions
65 lines (50 loc) · 1.83 KB
/
install.bat
File metadata and controls
65 lines (50 loc) · 1.83 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
@echo off
:: Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
:: SPDX-License-Identifier: Apache-2.0
set exe_name=smithy
set installer_path=%~dp0
set installer_drive=%~d0
set installer_exe=%installer_path%bin\%exe_name%
set install_path=%installer_drive%\Program Files\Smithy
:: Set the installation path
set choice_path=%install_path%
set /p choice_path=Install path [%install_path%]:
echo Installing Smithy to %choice_path%...
echo Checking for existing installation...
if exist "%choice_path%" goto upgrade
:start
:: Create a wrapper bat
(
echo @echo off
echo "%choice_path%\bin\smithy" %%*
) > "%installer_path%\%exe_name%.bat"
:: Copy the installation
xcopy /i /h /e /k "%installer_path%*" "%choice_path%\"
set "smithy_install_dir=%choice_path%"
powershell -Command "& { $installDir = $env:smithy_install_dir; $userPath = [Environment]::GetEnvironmentVariable('PATH','User'); if ([string]::IsNullOrEmpty($userPath)) { [Environment]::SetEnvironmentVariable('PATH', $installDir, 'User') } elseif (-not $userPath.Contains($installDir)) { [Environment]::SetEnvironmentVariable('PATH', $userPath.TrimEnd(';') + ';' + $installDir, 'User') } }"
if %ERRORLEVEL% neq 0 (
echo Failed to update PATH. You may need to add %choice_path%\bin to your PATH manually.
goto done
)
call "%choice_path%\bin\%exe_name%" warmup
echo You may now run '%exe_name% --version'
goto done
:: Check if upgrade is desired
:upgrade
echo Existing Smithy installation found...
set choice_upgrade=''
set /p choice_upgrade=Upgrade Smithy? [y/n]:
if '%choice_upgrade%'=='y' goto yes
if '%choice_upgrade%'=='n' goto no
echo "%choice_upgrade%" is not valid
goto upgrade
:no
echo Not upgrading Smithy...
goto done
:yes
echo Upgrading Smithy...
rmdir "%choice_path%" /s /q
goto start
:done
pause
exit