-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathdl_binaries.ps1
executable file
·47 lines (37 loc) · 1.34 KB
/
dl_binaries.ps1
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
#!/usr/bin/env -S pwsh -noprofile -nologo
# This script downloads the binaries for the most recent version of TabNine.
$TABNINE_UPDATE_SERVICE="https://update.tabnine.com"
if ($args.count -gt 0) {
$TABNINE_UPDATE_SERVICE=$args[0]
}
if ($null -ne $env:version) {
$version=$Env:version
}
else {
$version = invoke-webrequest -uri "$TABNINE_UPDATE_SERVICE/bundles/version" -usebasicparsing
}
if ([Environment]::Is64BitOperatingSystem) {
$targets = @(
'x86_64-pc-windows-gnu'
)
}
else {
$targets = @(
'i686-pc-windows-gnu'
)
}
if (test-path -path "binaries/$version") {
remove-item -path binaries -recurse -force | out-null
New-Item -Path "binaries/$version" -ItemType Directory -force | out-null
}
$targets | foreach-object {
$target = $_
$path = "$version/$target"
if (!(test-path -path "binaries/$version/$target")) { New-Item -Path "binaries/$version/$target" -ItemType Directory -force | out-null }
Write-Output "downloading $path"
invoke-webrequest -uri "$TABNINE_UPDATE_SERVICE/bundles/$path/TabNine.zip" -outfile "binaries/$path/TabNine.zip"
# Stop this iteration if the download failed
if (!(Test-Path "binaries/$path/TabNine.zip" -PathType Leaf)) {return}
expand-archive "binaries/$path/TabNine.zip" "binaries/$path"
remove-item -path "binaries/$path/TabNine.zip"
}