Skip to content

Commit ddf0f41

Browse files
fix: plugin failing to build on Windows (#419)
1 parent b606ceb commit ddf0f41

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

cmd/app/emoji.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"io"
88
"net/http"
99
"os"
10-
"path"
10+
"path/filepath"
1111
"strconv"
1212
"strings"
1313

@@ -157,8 +157,8 @@ func attachEmojis(a *data, fr FileReader) error {
157157
return err
158158
}
159159

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

163163
reader, err := fr.ReadFile(filePath)
164164

File renamed without changes.

lua/gitlab/emoji.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ local M = {
1010
}
1111

1212
M.init = function()
13-
local bin_path = state.settings.bin_path
14-
local emoji_path = bin_path
13+
local root_path = state.settings.root_path
14+
local emoji_path = root_path
15+
.. state.settings.file_separator
16+
.. "cmd"
1517
.. state.settings.file_separator
1618
.. "config"
1719
.. state.settings.file_separator

lua/gitlab/server.lua

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ end
8080
M.build = function(override)
8181
local file_path = u.current_file_path()
8282
local parent_dir = vim.fn.fnamemodify(file_path, ":h:h:h:h")
83-
state.settings.bin_path = parent_dir
84-
state.settings.bin = parent_dir .. (u.is_windows() and "\\bin.exe" or "/bin")
83+
84+
local bin_name = u.is_windows() and "bin.exe" or "bin"
85+
state.settings.root_path = parent_dir
86+
state.settings.bin = parent_dir .. u.path_separator .. "cmd" .. u.path_separator .. bin_name
8587

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

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

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

0 commit comments

Comments
 (0)