summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorxq114 <[email protected]>2023-03-03 14:53:12 +0800
committerxq114 <[email protected]>2023-03-03 14:53:12 +0800
commit92124435918095d86445faa13148899576f1ecdd (patch)
tree00335d75be3b09b12fc8e42dca750dd88bcc2e4f /scripts
parent0973396b09535d70d6c4c5613ea72bf5ee832137 (diff)
update get.ps1
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/get.ps178
1 files changed, 15 insertions, 63 deletions
diff --git a/scripts/get.ps1 b/scripts/get.ps1
index d117bfc45..4788eb464 100755
--- a/scripts/get.ps1
+++ b/scripts/get.ps1
@@ -11,7 +11,7 @@ param (
)
& {
- $LastRelease = "v2.7.6"
+ $LastRelease = "v2.7.7"
$ErrorActionPreference = 'Stop'
function writeErrorTip($msg) {
@@ -32,9 +32,9 @@ param (
if ($IsLinux -or $IsMacOS) {
writeErrorTip 'Install on *nix is not supported, try '
- writeErrorTip '(Use curl) "bash <(curl -fsSL https://raw.githubusercontent.com/xmake-io/xmake/master/scripts/get.sh)"'
+ writeErrorTip '(Use curl) "curl -fsSL https://xmake.io/shget.text | bash"'
writeErrorTip 'or'
- writeErrorTip '(Use wget) "bash <(wget https://raw.githubusercontent.com/xmake-io/xmake/master/scripts/get.sh -O -)"'
+ writeErrorTip '(Use wget) "wget https://xmake.io/shget.text -O - | bash"'
throw 'Unsupported platform'
}
@@ -85,9 +85,12 @@ param (
function xmakeInstall {
$outfile = Join-Path $temppath "$pid-xmake-installer.exe"
- $x64arch = @('AMD64', 'IA64', 'ARM64')
+ $x64arch = @('AMD64', 'IA64')
$arch = if ($env:PROCESSOR_ARCHITECTURE -in $x64arch -or $env:PROCESSOR_ARCHITEW6432 -in $x64arch) { 'x64' } else { 'x86' }
$winarch = if ($env:PROCESSOR_ARCHITECTURE -in $x64arch -or $env:PROCESSOR_ARCHITEW6432 -in $x64arch) { 'win64' } else { 'win32' }
+ if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') {
+ Write-Host "Unsupported host architecture detected: ARM64."
+ }
$url = if ($v -is [version]) {
"https://github.com/xmake-io/xmake/releases/download/v$v/xmake-v$v.$winarch.exe"
} else {
@@ -131,66 +134,15 @@ param (
}
function registerTabCompletion {
-
- function writeDataToFile($file) {
- $content = ''
- if (Test-Path $file -PathType Leaf) {
- $content = Get-Content $file -Raw
- }
-
- try {
- New-Item $(Split-Path $file -Parent) -ItemType Directory -Force | Out-Null
- Set-Content $file $content -NoNewline
- } catch {
- writeErrorTip "Failed to append to profile!"
- writeErrorTip "Please try again as administrator"
- return
- }
-
- if ($content) {
- $content = $content -replace "`n# >>> xmake >>>`n[\S\s]*?`n# <<< xmake <<<`n", ""
- }
- try {
- $url = if ($v -is [version]) {
- "https://fastly.jsdelivr.net/gh/xmake-io/xmake@v$v/scripts/register-completions.ps1"
- } else {
- "https://fastly.jsdelivr.net/gh/xmake-io/xmake@$v/scripts/register-completions.ps1"
- }
- $appendcontent = (Invoke-Webrequest $url -UseBasicParsing).Content
- if ($appendcontent -is [byte[]]) {
- $appendcontent = [System.Text.Encoding]::UTF8.GetString($appendcontent)
- }
- } catch {
- writeErrorTip 'Download failed!'
- writeErrorTip 'Check your network or... the news of S3 break'
- return
- }
- Set-Content $file "$content`n# >>> xmake >>>`n$appendcontent`n# <<< xmake <<<`n" -NoNewline
- . $file
- Write-Host "Tab completion installed"
- }
- $message = 'Tab completion service'
- $question = 'Would you like to install tab completion service of xmake to your profile?'
-
- $choices = @(
- (New-Object Management.Automation.Host.ChoiceDescription -ArgumentList @(
- 'For &all users',
- "Install for all users, writes to $($PROFILE.AllUsersAllHosts), admin privilege is needed.")),
- (New-Object Management.Automation.Host.ChoiceDescription -ArgumentList @(
- 'Just for &me',
- "Install for current user, writes to $($PROFILE.CurrentUserAllHosts).")),
- (New-Object Management.Automation.Host.ChoiceDescription -ArgumentList @(
- 'Just for this &host',
- "Install for current user current host, writes to $($PROFILE.CurrentUserCurrentHost).")),
- (New-Object Management.Automation.Host.ChoiceDescription -ArgumentList @(
- '&No',
- "Do not install xmake's tab completion service."))
- )
- switch ($Host.UI.PromptForChoice($message, $question, $choices, 1)) {
- 0 { writeDataToFile($PROFILE.AllUsersAllHosts) }
- 1 { writeDataToFile($PROFILE.CurrentUserAllHosts) }
- 2 { writeDataToFile($PROFILE.CurrentUserCurrentHost) }
+ Write-Host "Tab completion service"
+ try {
+ xmake update --integrate
+ } catch {
+ writeErrorTip "Failed to register tab completion!"
+ writeErrorTip 'Please try "xmake update --integrate" to register manually.'
+ return
}
+ Write-Host "Tab completion installed"
}
checkTempAccess