@@ -6,42 +6,33 @@ local await = async.wait_handle_ok
66local M = {}
77
88function M .is_available (package_name ,package_version )
9+ -- guard clause
910local has_pkg = mason_reg .has_package (package_name )
10-
1111if not has_pkg then
1212return false
1313end
1414
15- local has_version = false
16-
15+ -- check
1716local pkg = mason_reg .get_package (package_name )
18- pkg :get_installed_version (function (success ,version )
19- if success and version == package_version then
20- has_version = true
21- end
22- end )
17+ local version = pkg :get_installed_version ()
18+ local has_version = version == package_version
2319
2420return has_version
2521end
2622
2723function M .is_installed (package_name ,package_version )
24+ -- guard clause
2825local pkg = mason_reg .get_package (package_name )
2926local is_installed = pkg :is_installed ()
30-
3127if not is_installed then
3228return false
3329end
3430
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 )
31+ -- check
32+ local installed_version = pkg :get_installed_version ()
33+ is_installed = installed_version == package_version
4334
44- return installed_version == package_version
35+ return is_installed
4536end
4637
4738function M .is_outdated (packages )