tools/vself: minor optimization (#7877)
parent
5c1981379e
commit
c66ee8aa61
|
@ -23,13 +23,12 @@ fn main() {
|
|||
// The user just wants an independent copy of v, and so we are done.
|
||||
return
|
||||
}
|
||||
backup_old_version_and_rename_newer()
|
||||
backup_old_version_and_rename_newer() or { panic(err) }
|
||||
println('V built successfully!')
|
||||
}
|
||||
|
||||
fn compile(vroot string, cmd string) {
|
||||
result := os.exec(cmd) or {
|
||||
panic(err)
|
||||
}
|
||||
result := os.exec(cmd) or { panic(err) }
|
||||
if result.exit_code != 0 {
|
||||
eprintln('cannot compile to `$vroot`: \n$result.output')
|
||||
exit(1)
|
||||
|
@ -39,13 +38,13 @@ fn compile(vroot string, cmd string) {
|
|||
}
|
||||
}
|
||||
|
||||
fn backup_old_version_and_rename_newer() {
|
||||
fn backup_old_version_and_rename_newer() ? {
|
||||
v_file := if os.user_os() == 'windows' { 'v.exe' } else { 'v' }
|
||||
v2_file := if os.user_os() == 'windows' { 'v2.exe' } else { 'v2' }
|
||||
bak_file := if os.user_os() == 'windows' { 'v_old.exe' } else { 'v_old' }
|
||||
if os.exists(bak_file) {
|
||||
os.rm(bak_file)
|
||||
os.rm(bak_file) ?
|
||||
}
|
||||
os.mv(v_file, bak_file)
|
||||
os.mv(v2_file, v_file)
|
||||
os.mv(v_file, bak_file) ?
|
||||
os.mv(v2_file, v_file) ?
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue