refactor(installer): change api

This commit is contained in:
Smirnov Oleksandr 2023-07-19 20:44:22 +03:00
parent 263692f865
commit a3201f701e
2 changed files with 10 additions and 6 deletions

View file

@ -4,7 +4,7 @@ local uc = require "gopher._utils.commands"
local gopher = {}
gopher.setup = require("gopher.config").setup
gopher.install_deps = require "gopher.installer"
gopher.install_deps = require("gopher.installer").install_deps
gopher.impl = require("gopher.impl").impl
gopher.iferr = require("gopher.iferr").iferr
gopher.comment = require "gopher.comment"

View file

@ -1,3 +1,8 @@
local Job = require "plenary.job"
local c = require("gopher.config").commands
local u = require "gopher._utils"
local installer = {}
local urls = {
gomodifytags = "github.com/fatih/gomodifytags",
impl = "github.com/josharian/impl",
@ -8,13 +13,10 @@ local urls = {
---@param pkg string
local function install(pkg)
local Job = require "plenary.job"
local u = require "gopher._utils"
local url = urls[pkg] .. "@latest"
Job:new({
command = "go",
command = c.go,
args = { "install", url },
on_exit = function(_, retval)
if retval ~= 0 then
@ -28,8 +30,10 @@ local function install(pkg)
end
---Install required go deps
return function()
function installer.install_deps()
for pkg, _ in pairs(urls) do
install(pkg)
end
end
return installer