Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove incorrect use of plenary.path #159

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lua/neotest-java/core/spec_builder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function SpecBuilder.build_spec(args, project_type, config)

-- make sure outputDir is created to operate in it
local output_dir = build_tools.get(project_type).get_output_dir()
local output_dir_parent = path:new(output_dir):parent().filename
local output_dir_parent = compatible_path(path:new(output_dir):parent().filename)

vim.uv.fs_mkdir(output_dir_parent, 493)
vim.uv.fs_mkdir(output_dir, 493)
Expand Down
5 changes: 3 additions & 2 deletions lua/neotest-java/types/project.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ local detect_project_type = require("neotest-java.util.detect_project_type")
local Module = require("neotest-java.types.module")
local scan = require("plenary.scandir")
local logger = require("neotest-java.logger")
local Path = require("plenary.path")
local should_ignore_path = require("neotest-java.util.should_ignore_path")
local compatible_path = require("neotest-java.util.compatible_path")
local Path = require("plenary.path")

---@class neotest-java.Project
---@field root_dir string
Expand Down Expand Up @@ -42,7 +43,7 @@ function Project:get_modules()
---@type table<neotest-java.Module>
local modules = {}
for _, dir in ipairs(dirs) do
local base_dir = Path:new(dir):parent().filename
local base_dir = compatible_path(Path:new(dir):parent().filename)
local mod = Module.new(base_dir, self.build_tool)
modules[#modules + 1] = mod
end
Expand Down
11 changes: 5 additions & 6 deletions lua/neotest-java/util/write_file.lua
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
local Path = require("plenary.path")
local nio = require("nio")
local compatible_path = require("neotest-java.util.compatible_path")
local Path = require("plenary.path")

---@param filepath string
---@param content string
local function write_file(filepath, content)
-- for os compatibibility
local _filepath = Path:new(filepath)
local _filepath = compatible_path(filepath)
-- create parent directories if they don't exist
nio.fn.mkdir(_filepath:parent():absolute(), "p")

local compatible_path = _filepath:absolute()
nio.fn.mkdir(Path:new(_filepath):parent():absolute(), "p")

local file = io.open(compatible_path, "w") or error("Could not open file for writing: " .. compatible_path)
local file = io.open(_filepath, "w") or error("Could not open file for writing: " .. _filepath)
local buffer = ""
for i = 1, #content do
buffer = buffer .. content:sub(i, i)
Expand Down