File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -186,6 +186,43 @@ extract_file() {
186186 esac
187187}
188188
189+ # validate_remote_version
190+ # Get remote version data by GitHub api (Get a release by tag name)
191+ validate_remote_version () {
192+ local version
193+ # GitHub get release by tag name api url
194+ local tag_url
195+
196+ version=" $1 "
197+
198+ tag_url=" https://api.github.com/repos/denoland/deno/releases/tags/$version "
199+
200+ if [ -x " $( command -v wget) " ]
201+ then
202+ cmd=" wget -O- $tag_url -nv"
203+ elif [ -x " $( command -v curl) " ]
204+ then
205+ cmd=" curl -s $tag_url "
206+ else
207+ echo " wget or curl is required."
208+ exit 1
209+ fi
210+
211+ if ! response=$( $cmd )
212+ then
213+ echo " Failed to getting deno $version data"
214+ exit 1
215+ fi
216+
217+ tag_name=$( echo " $response " | grep tag_name | cut -d ' "' -f 4)
218+
219+ if [ -z " $tag_name " ]
220+ then
221+ echo " Deno '$version ' not found, use 'ls-remote' command to get available versions."
222+ exit 1
223+ fi
224+ }
225+
189226install_version () {
190227 local version
191228
@@ -203,6 +240,8 @@ install_version() {
203240 exit 0
204241 fi
205242
243+ validate_remote_version " $version "
244+
206245 get_package_data " $version "
207246
208247 if [ ! -f " $DVM_DIR /download/$version /deno.$DVM_TARGET_TYPE " ]
You can’t perform that action at this time.
0 commit comments