@@ -6,33 +6,42 @@ local await = async.wait_handle_ok
66local M = {}
77
88function M .is_available (package_name ,package_version )
9- -- guard clause
109local has_pkg = mason_reg .has_package (package_name )
10+
1111if not has_pkg then
1212return false
1313end
1414
15- -- check
15+ local has_version = false
16+
1617local pkg = mason_reg .get_package (package_name )
17- local version = pkg :get_installed_version ()
18- local has_version = version == package_version
18+ pkg :get_installed_version (function (success ,version )
19+ if success and version == package_version then
20+ has_version = true
21+ end
22+ end )
1923
2024return has_version
2125end
2226
2327function M .is_installed (package_name ,package_version )
24- -- guard clause
2528local pkg = mason_reg .get_package (package_name )
2629local is_installed = pkg :is_installed ()
30+
2731if not is_installed then
2832return false
2933end
3034
31- -- check
32- local installed_version = pkg :get_installed_version ()
33- is_installed = installed_version == package_version
35+ local installed_version
36+ pkg :get_installed_version (function (ok ,version )
37+ if not ok then
38+ return
39+ end
40+
41+ installed_version = version
42+ end )
3443
35- return is_installed
44+ return installed_version == package_version
3645end
3746
3847function M .is_outdated (packages )