From 3990cbf2b4e3ba0d20c8beaab6e8a80954a8b75e Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+ttytm@users.noreply.github.com> Date: Fri, 10 Nov 2023 23:35:24 +0100 Subject: [PATCH] tools: fix already installed detection when running `v install` without args --- cmd/tools/vpm/dependency_test.v | 4 +++- cmd/tools/vpm/install.v | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/tools/vpm/dependency_test.v b/cmd/tools/vpm/dependency_test.v index 373356354fd369..31b6795f0500b3 100644 --- a/cmd/tools/vpm/dependency_test.v +++ b/cmd/tools/vpm/dependency_test.v @@ -49,7 +49,7 @@ fn test_install_dependencies_in_module_dir() { } assert v_mod.dependencies == ['markdown', 'pcre', 'https://github.com/spytheman/vtray'] // Run `v install` - res := os.execute_or_exit('${v} install') + mut res := os.execute_or_exit('${v} install --once') assert res.output.contains('Detected v.mod file inside the project directory. Using it...') assert res.output.contains('Installing module `markdown`') assert res.output.contains('Installing module `pcre`') @@ -57,6 +57,8 @@ fn test_install_dependencies_in_module_dir() { assert get_mod_name(os.join_path(test_path, 'markdown', 'v.mod')) == 'markdown' assert get_mod_name(os.join_path(test_path, 'pcre', 'v.mod')) == 'pcre' assert get_mod_name(os.join_path(test_path, 'vtray', 'v.mod')) == 'vtray' + res = os.execute_or_exit('${v} install --once') + assert res.output.contains('All modules are already installed.'), res.output } fn test_resolve_external_dependencies_during_module_install() { diff --git a/cmd/tools/vpm/install.v b/cmd/tools/vpm/install.v index 0078e1fe9026cc..5ce1094bc3ac2f 100644 --- a/cmd/tools/vpm/install.v +++ b/cmd/tools/vpm/install.v @@ -37,6 +37,7 @@ fn vpm_install(query []string) { vpm_log(@FILE_LINE, @FN, 'Installed modules: ${installed_modules}') if installed_modules.len > 0 && settings.is_once { + num_to_install := vpm_modules.len + external_modules.len mut already_installed := []string{} if external_modules.len > 0 { mut i_deleted := []int{} @@ -64,7 +65,7 @@ fn vpm_install(query []string) { } if already_installed.len > 0 { verbose_println('Already installed modules: ${already_installed}') - if already_installed.len == query.len { + if already_installed.len == num_to_install { println('All modules are already installed.') exit(0) }