refactor(installer): change api
This commit is contained in:
parent
263692f865
commit
a3201f701e
2 changed files with 10 additions and 6 deletions
|
|
@ -4,7 +4,7 @@ local uc = require "gopher._utils.commands"
|
||||||
local gopher = {}
|
local gopher = {}
|
||||||
|
|
||||||
gopher.setup = require("gopher.config").setup
|
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.impl = require("gopher.impl").impl
|
||||||
gopher.iferr = require("gopher.iferr").iferr
|
gopher.iferr = require("gopher.iferr").iferr
|
||||||
gopher.comment = require "gopher.comment"
|
gopher.comment = require "gopher.comment"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,8 @@
|
||||||
|
local Job = require "plenary.job"
|
||||||
|
local c = require("gopher.config").commands
|
||||||
|
local u = require "gopher._utils"
|
||||||
|
local installer = {}
|
||||||
|
|
||||||
local urls = {
|
local urls = {
|
||||||
gomodifytags = "github.com/fatih/gomodifytags",
|
gomodifytags = "github.com/fatih/gomodifytags",
|
||||||
impl = "github.com/josharian/impl",
|
impl = "github.com/josharian/impl",
|
||||||
|
|
@ -8,13 +13,10 @@ local urls = {
|
||||||
|
|
||||||
---@param pkg string
|
---@param pkg string
|
||||||
local function install(pkg)
|
local function install(pkg)
|
||||||
local Job = require "plenary.job"
|
|
||||||
local u = require "gopher._utils"
|
|
||||||
|
|
||||||
local url = urls[pkg] .. "@latest"
|
local url = urls[pkg] .. "@latest"
|
||||||
|
|
||||||
Job:new({
|
Job:new({
|
||||||
command = "go",
|
command = c.go,
|
||||||
args = { "install", url },
|
args = { "install", url },
|
||||||
on_exit = function(_, retval)
|
on_exit = function(_, retval)
|
||||||
if retval ~= 0 then
|
if retval ~= 0 then
|
||||||
|
|
@ -28,8 +30,10 @@ local function install(pkg)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Install required go deps
|
---Install required go deps
|
||||||
return function()
|
function installer.install_deps()
|
||||||
for pkg, _ in pairs(urls) do
|
for pkg, _ in pairs(urls) do
|
||||||
install(pkg)
|
install(pkg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return installer
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue