Skip to content

Commit

Permalink
analyzer: merge creation of vtmp directory for check-updates/up comma…
Browse files Browse the repository at this point in the history
…nds (#126)
  • Loading branch information
lcheylus authored Sep 20, 2024
1 parent 60f2bc0 commit 8752a59
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
5 changes: 0 additions & 5 deletions src/check-updates.v
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
module main

import cli
import os

fn check_updates_cmd(_ cli.Command) ! {
if !os.exists(analyzer_dir) {
os.mkdir(analyzer_dir)!
}

download_install_vsh()!
call_install_vsh('check-updates')!
}
7 changes: 1 addition & 6 deletions src/up.v
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@ import cli
import term
import os

pub const analyzer_dir = os.join_path(os.vtmp_dir(), 'v-analyzer')
pub const analyzer_install_script_download_path = 'https://raw.githubusercontent.com/vlang/v-analyzer/main/install.vsh'
pub const analyzer_install_script_path = os.join_path(analyzer_dir, 'install.vsh')
pub const analyzer_install_script_path = os.join_path(os.vtmp_dir(), 'v-analyzer', 'install.vsh')

fn up_cmd(cmd cli.Command) ! {
if !os.exists(analyzer_dir) {
os.mkdir(analyzer_dir)!
}

download_install_vsh()!

is_nightly := cmd.flags.get_bool('nightly') or { false }
Expand Down
5 changes: 5 additions & 0 deletions src/utils.v
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ pub fn successln(msg string) {
}

pub fn download_install_vsh() ! {
download_dir := os.join_path(os.vtmp_dir(), 'v-analyzer')
if !os.exists(download_dir) {
os.mkdir(download_dir) or { return error('Failed to create tmp dir: ${err}') }
}

http.download_file(analyzer_install_script_download_path, analyzer_install_script_path) or {
return error('Failed to download script: ${err}')
}
Expand Down

0 comments on commit 8752a59

Please sign in to comment.