Skip to content

Commit

Permalink
refactor: break out function
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikaverpil committed Sep 8, 2024
1 parent 4f8f15a commit 6cfb2b6
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lua/neotest-golang/lib/cmd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@ local json = require("neotest-golang.lib.json")

local M = {}

--- Call 'go list -json {go_list_args...} ./...' to get test file data
--- @param cwd string
function M.golist_data(cwd)
-- call 'go list -json {go_list_args...} ./...' to get test file data

-- combine base command, user args and packages(./...)
local cmd = { "go", "list", "-json" }
vim.list_extend(cmd, options.get().go_list_args or {})
vim.list_extend(cmd, { "./..." })

local cmd = M.golist_command()
local go_list_command_concat = table.concat(cmd, " ")
logger.debug("Running Go list: " .. go_list_command_concat .. " in " .. cwd)
local result = vim.system(cmd, { cwd = cwd, text = true }):wait()
Expand All @@ -36,6 +32,13 @@ function M.golist_data(cwd)
return json.decode_from_string(output), err
end

function M.golist_command()
local cmd = { "go", "list", "-json" }
vim.list_extend(cmd, options.get().go_list_args or {})
vim.list_extend(cmd, { "./..." })
return cmd
end

function M.test_command_in_package(package_or_path)
local go_test_required_args = { package_or_path }
local cmd, json_filepath = M.test_command(go_test_required_args)
Expand Down

0 comments on commit 6cfb2b6

Please sign in to comment.