Skip to content

Commit

Permalink
fix: remove incorrect use of plenary.path (#159)
Browse files Browse the repository at this point in the history
Relates to #135
  • Loading branch information
rcasia authored Oct 8, 2024
1 parent 6375aef commit 4fe7a53
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
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

0 comments on commit 4fe7a53

Please sign in to comment.