-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclojure-install.bat
165 lines (129 loc) · 4.28 KB
/
clojure-install.bat
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
@echo off
rem Clojure Installer for Windows
rem Copyright (c) 2020 Michael Chen
rem Licensed under MIT
rem Check whether Git is available.
git --version 1>nul 2>&1 || (
echo No Git on the system >&2
exit /B 1
)
rem Get prefix from user input.
set prefix=%1
rem Fallback to default prefix.
if "x%prefix%" == "x" (
set prefix=%USERPROFILE%
)
if "%prefix:~-1%" neq "\" (
set prefix=%prefix%\
)
set clojure_root=%prefix%clojure\
set jline_root=%prefix%jline1\
rem Save current working directory.
set cwd=%CD%
if exist %clojure_root% (
cd %clojure_root% || (
echo Failed to go to %clojure_root% >&2
exit /B 1
)
rem Update a local Clojure repo if it exists.
git pull
) else (
rem Clone a Clojure repo if it doesn't exist.
git clone https://github.com/clojure/clojure.git %clojure_root%
cd %clojure_root% || (
echo Failed to go to %clojure_root% >&2
exit /B 1
)
)
rem Check whether PowerShell is available.
powershell -Help >nul 2>&1 || (
echo No PowerShell on the system >&2
exit /B 1
)
rem Download clojure.bat
powershell -Command ^
"Invoke-WebRequest -Uri https://raw.githubusercontent.com/cwchentw/clojure-install/master/clojure/cljrun.bat -OutFile %clojure_root%cljrun.bat"
rem Check whether cljrun.bat exists.
if not exist %clojure_root%cljrun.bat (
echo Failed to download cljrun.bat >&2
exit /B 1
)
powershell -Command ^
"Invoke-WebRequest -Uri https://raw.githubusercontent.com/cwchentw/clojure-install/master/clojure/clojure.bat -OutFile %clojure_root%clojure.bat"
rem Check whether clojure.bat exists.
if not exist %clojure_root%clojure.bat (
echo Failed to download clojure.bat >&2
exit /B 1
)
powershell -Command ^
"Invoke-WebRequest -Uri https://raw.githubusercontent.com/cwchentw/clojure-install/master/clojure/clj.bat -OutFile %clojure_root%clj.bat"
rem Check whether clj.bat exists.
if not exist %clojure_root%clj.bat (
echo Failed to download clj.bat >&2
exit /B 1
)
mkdir scripts || (
echo Failed to create %clojure_root%scripts\ >&2
exit /B 1
)
rem Download build.bat for Clojure
powershell -Command ^
"Invoke-WebRequest -Uri https://raw.githubusercontent.com/cwchentw/clojure-install/master/clojure/build.bat -OutFile %clojure_root%\scripts\build.bat"
rem Check whether build.bat exists.
if not exist %clojure_root%\scripts\build.bat (
echo Failed to download build.bat for Clojure >&2
exit /B 1
)
rem Download clean.bat for Clojure
powershell -Command ^
"Invoke-WebRequest -Uri https://raw.githubusercontent.com/cwchentw/clojure-install/master/clojure/clean.bat -OutFile %clojure_root%\scripts\clean.bat"
rem Check whether clean.bat exists.
if not exist %clojure_root%scripts\clean.bat (
echo Failed to download clean.bat for Clojure >&2
exit /B 1
)
call %clojure_root%\scripts\clean.bat
call %clojure_root%\scripts\build.bat
cd %cwd%
if exist %jline_root% (
cd %jline_root% || (
echo Failed to go to %jline_root% >&2
exit /B 1
)
rem Update a local jline 1.x repo if it exists.
git pull
) else (
rem Clone a jline 1.x repo if it doesn't exist.
git clone https://github.com/jline/jline1.git %jline_root%
cd %jline_root% || (
echo Failed to go to %jline_root% >&2
exit /B 1
)
)
rem Download build.bat for jline 1.x
powershell -Command ^
"Invoke-WebRequest -Uri https://raw.githubusercontent.com/cwchentw/clojure-install/master/jline1/build.bat -OutFile %jline_root%\build.bat"
if not exist %jline_root%build.bat (
echo Failed to download build.bat for jline 1.x >&2
exit /B 1
)
rem Download clean.bat for jline 1.x
powershell -Command ^
"Invoke-WebRequest -Uri https://raw.githubusercontent.com/cwchentw/clojure-install/master/jline1/clean.bat -OutFile %jline_root%\clean.bat"
rem Check whether clean.bat exists.
if not exist %jline_root%clean.bat (
echo Failed to download clean.bat for jline 1.x >&2
exit /B 1
)
call %jline_root%\clean.bat
call %jline_root%\build.bat
copy %jline_root%\target\jline-1.1-SNAPSHOT.jar %clojure_root% || (
echo Failed to copy %jline_root%\target\jline-1.1-SNAPSHOT.jar to %clojure_root% >&2
exit /B 1
)
cd %cwd% || (
echo Failed to go to %cwd% >&2
exit /B 1
)
rmdir /s /q %jline_root%
echo Remember to add %clojure_root% to PATH variable