v up: simplify

pull/3795/head
yuyi 2020-02-21 00:41:55 +08:00 committed by GitHub
parent 34d926350b
commit f267a88ddf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 8 deletions

View File

@ -3,24 +3,34 @@ module main
import ( import (
os os
filepath filepath
v.pref
) )
fn main() { fn main() {
println('Updating V...') println('Updating V...')
vroot := filepath.dir(os.getenv('VEXE')) vroot := filepath.dir(pref.vexe_path())
os.chdir(vroot) os.chdir(vroot)
s := os.exec('git -C "$vroot" pull --rebase origin master') or { panic(err) } // git pull
println(s.output) s := os.exec('git pull --rebase origin master') or {
$if windows { panic(err)
v_backup_file := '$vroot/v_old.exe' }
if os.exists( v_backup_file ) { println(s.output)
os.rm( v_backup_file )
$if windows {
v_backup_file := 'v_old.exe'
if os.exists(v_backup_file) {
os.rm(v_backup_file)
}
os.mv('v.exe', v_backup_file)
s2 := os.exec('make.bat') or {
panic(err)
} }
os.mv('$vroot/v.exe', v_backup_file)
s2 := os.exec('"$vroot/make.bat"') or { panic(err) }
println(s2.output) println(s2.output)
} $else { } $else {
s2 := os.exec('make -C "$vroot"') or { panic(err) } s2 := os.exec('make') or {
panic(err)
}
println(s2.output) println(s2.output)
} }
} }