Skip to content

Commit e44aae1

Browse files
committed
Refactor: Improve kit detection
1 parent e547e0d commit e44aae1

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

codebook.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
words = ["cxx"]

lua/cmake-tools/scanner.lua

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@ local scanner = {}
22

33
--Helper functions
44
local function execute_command(cmd)
5-
local handle = io.popen(cmd .. " 2>&1")
6-
if handle == nil then
7-
return false, -1, ""
5+
print(cmd)
6+
7+
if cmd == nil then
8+
return false, -1, nil
89
end
9-
local result = handle:read("*a")
10+
local result = vim.system(cmd, { text = true }):wait()
1011
if result == nil then
11-
result = ""
12-
end
13-
local success, exit_code = handle:close()
14-
if success == nil then
15-
return false, exit_code or -1, result
12+
return false, -1, nil
1613
end
17-
return true, 0, result
14+
print(result.stdout)
15+
return true, result.code, result.stdout
1816
end
1917

2018
local function split_path(path_env)
@@ -27,7 +25,7 @@ local function split_path(path_env)
2725
end
2826

2927
local function get_gcc_version(gcc_path)
30-
local success, exit_code, output = execute_command('"' .. gcc_path .. '" --version')
28+
local success, exit_code, output = execute_command({ "gcc", "--version" })
3129
if output == nil then
3230
return nil
3331
end
@@ -38,7 +36,8 @@ local function get_gcc_version(gcc_path)
3836
end
3937

4038
local function get_clang_version(clang_path)
41-
local success, exit_code, output = execute_command('"' .. clang_path .. '" --version ')
39+
local success, exit_code, output = execute_command({ "clang", "--version" })
40+
4241
if output == nil then
4342
return nil
4443
end

0 commit comments

Comments
 (0)