From a3201f701e87c29138cb2ad1a3e531a6b4ace6a5 Mon Sep 17 00:00:00 2001 From: Smirnov Oleksandr Date: Wed, 19 Jul 2023 20:44:22 +0300 Subject: [PATCH] refactor(installer): change api --- lua/gopher/init.lua | 2 +- lua/gopher/installer.lua | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lua/gopher/init.lua b/lua/gopher/init.lua index dff99ad..2f6f32e 100644 --- a/lua/gopher/init.lua +++ b/lua/gopher/init.lua @@ -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" diff --git a/lua/gopher/installer.lua b/lua/gopher/installer.lua index fdd6242..cfe3e78 100644 --- a/lua/gopher/installer.lua +++ b/lua/gopher/installer.lua @@ -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