summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorTitanSnow <[email protected]>2017-04-22 14:54:31 +0800
committerTitanSnow <[email protected]>2017-04-22 14:54:38 +0800
commit2ba18fd87e2af7461dd675bfefd6326c1c1e444f (patch)
tree8d74abd0c1b0b89b1a8d6908670eaf94496dfc39 /scripts
parent4506a57c46ece41caf443b96674cf7b11490b4f6 (diff)
fix Invoke-Expression quickly exit when error
Diffstat (limited to 'scripts')
-rw-r--r--scripts/get.ps118
1 files changed, 13 insertions, 5 deletions
diff --git a/scripts/get.ps1 b/scripts/get.ps1
index c6de72b14..92db7c666 100644
--- a/scripts/get.ps1
+++ b/scripts/get.ps1
@@ -4,6 +4,14 @@
& {
+Function myExit($code){
+ if($code -is [int] -and $code -ne 0){
+ throw $Error[0]
+ }else{
+ break
+ }
+}
+
$temppath=($env:TMP,$env:TEMP,'.' -ne $null)[0]
$outfile=$temppath+"\$pid-xmake-installer.exe"
try{
@@ -12,7 +20,7 @@ try{
}catch{
Write-Host 'Cannot write to temp path'
Write-Host 'Please set environment var "TMP" to another path'
- Exit 1
+ myExit 1
}
$ver='v2.1.3'
Write-Host 'Start downloading... Hope amazon S3 is not broken again'
@@ -21,7 +29,7 @@ try{
}catch{
Write-Host 'Download failed!'
Write-Host 'Check your network or... the news of S3 break'
- Exit 1
+ myExit 1
}
Write-Host 'Start installation... Hope your antivirus doesn''t trouble'
$installdir=$HOME+'\xmake'
@@ -32,7 +40,7 @@ try{
Remove-Item "$outfile"
Write-Host 'Install failed!'
Write-Host 'Close your antivirus then try again'
- Exit 1
+ myExit 1
}
Remove-Item "$outfile"
Write-Host 'Adding to PATH... almost done'
@@ -43,7 +51,7 @@ try{
}catch{
Write-Host 'Everything is showing installation has finished'
Write-Host 'But xmake could not run... Why?'
- Exit 1
+ myExit 1
}
$branch='master'
Write-Host "Pulling xmake from branch $branch"
@@ -53,7 +61,7 @@ try{
}catch{
Write-Host 'Pull Failed!'
Write-Host 'xmake is now available but may not be newest'
- Exit
+ myExit
}
Write-Host 'Expanding archive...'
New-Item -Path "$temppath" -Name "$pid-xmake-repo" -ItemType "directory" -Force