From 924fd2bf2a1e5a1d426f44bdaed885a94b10a536 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Thu, 28 Jan 2021 00:45:38 +0200 Subject: [PATCH] tools: improve the diagnostic messages from `v up` and `v self` even more --- cmd/tools/vself.v | 13 ++++++++----- cmd/tools/vup.v | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cmd/tools/vself.v b/cmd/tools/vself.v index 16a3218fb0..7a312ab5cc 100644 --- a/cmd/tools/vself.v +++ b/cmd/tools/vself.v @@ -42,16 +42,19 @@ fn compile(vroot string, cmd string) { fn backup_old_version_and_rename_newer() ?bool { mut errors := []string{} - 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' } + short_v_file := if os.user_os() == 'windows' { 'v.exe' } else { 'v' } + short_v2_file := if os.user_os() == 'windows' { 'v2.exe' } else { 'v2' } + short_bak_file := if os.user_os() == 'windows' { 'v_old.exe' } else { 'v_old' } + v_file := os.real_path(short_v_file) + v2_file := os.real_path(short_v2_file) + bak_file := os.real_path(short_bak_file) if os.exists(bak_file) { os.rm(bak_file) or { errors << 'failed removing $bak_file: $err' } } os.mv(v_file, bak_file) or { errors << err } - os.mv(v2_file, v_file) or { errors << err } + os.mv(v2_file, v_file) or { panic(err) } if errors.len > 0 { - return error('backup errors:\n >> ' + errors.join('\n >> ')) + eprintln('backup errors:\n >> ' + errors.join('\n >> ')) } return true } diff --git a/cmd/tools/vup.v b/cmd/tools/vup.v index 3130049444..b18fa6c05b 100644 --- a/cmd/tools/vup.v +++ b/cmd/tools/vup.v @@ -108,7 +108,7 @@ fn (app App) show_current_v_version() { fn (app App) backup(file string) { backup_file := '${file}_old.exe' if os.exists(backup_file) { - os.rm(backup_file) or { panic(err) } + os.rm(backup_file) or { eprintln('failed removing $backup_file: $err') } } os.mv(file, backup_file) or { panic(err) } }