Skip to content

Commit

Permalink
fix: plugin failing to build on Windows (#419)
Browse files Browse the repository at this point in the history
  • Loading branch information
harrisoncramer authored Nov 12, 2024
1 parent b606ceb commit ddf0f41
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
6 changes: 3 additions & 3 deletions cmd/app/emoji.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"io"
"net/http"
"os"
"path"
"path/filepath"
"strconv"
"strings"

Expand Down Expand Up @@ -157,8 +157,8 @@ func attachEmojis(a *data, fr FileReader) error {
return err
}

binPath := path.Dir(e)
filePath := fmt.Sprintf("%s/config/emojis.json", binPath)
binPath := filepath.Dir(e)
filePath := filepath.Join(binPath, "config", "emojis.json")

reader, err := fr.ReadFile(filePath)

Expand Down
File renamed without changes.
6 changes: 4 additions & 2 deletions lua/gitlab/emoji.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ local M = {
}

M.init = function()
local bin_path = state.settings.bin_path
local emoji_path = bin_path
local root_path = state.settings.root_path
local emoji_path = root_path
.. state.settings.file_separator
.. "cmd"
.. state.settings.file_separator
.. "config"
.. state.settings.file_separator
Expand Down
20 changes: 10 additions & 10 deletions lua/gitlab/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ end
M.build = function(override)
local file_path = u.current_file_path()
local parent_dir = vim.fn.fnamemodify(file_path, ":h:h:h:h")
state.settings.bin_path = parent_dir
state.settings.bin = parent_dir .. (u.is_windows() and "\\bin.exe" or "/bin")

local bin_name = u.is_windows() and "bin.exe" or "bin"
state.settings.root_path = parent_dir
state.settings.bin = parent_dir .. u.path_separator .. "cmd" .. u.path_separator .. bin_name

if not override then
local binary_exists = vim.loop.fs_stat(state.settings.bin)
Expand All @@ -90,17 +92,15 @@ M.build = function(override)
end
end

local cmd = u.is_windows() and "cd %s\\cmd && go build -o bin.exe && move bin.exe ..\\"
or "cd %s/cmd && go build -o bin && mv bin ../bin"
local res = vim
.system({ "go", "build", "-o", bin_name }, { cwd = state.settings.root_path .. u.path_separator .. "cmd" })
:wait()

local command = string.format(cmd, state.settings.bin_path)
local null = u.is_windows() and " >NUL" or " > /dev/null"
local installCode = os.execute(command .. null)
if installCode ~= 0 then
u.notify("Could not install gitlab.nvim!", vim.log.levels.ERROR)
if res.code ~= 0 then
u.notify(string.format("Failed to install with status code %d:\n%s", res.code, res.stderr), vim.log.levels.ERROR)
return false
end
u.notify("Gitlab.nvim installed successfully!", vim.log.levels.INFO)
u.notify("Installed successfully!", vim.log.levels.INFO)
return true
end

Expand Down

0 comments on commit ddf0f41

Please sign in to comment.