diff --git a/lua/neotest-java/core/spec_builder.lua b/lua/neotest-java/core/spec_builder.lua index fae18f5..d8a62ef 100644 --- a/lua/neotest-java/core/spec_builder.lua +++ b/lua/neotest-java/core/spec_builder.lua @@ -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) diff --git a/lua/neotest-java/types/project.lua b/lua/neotest-java/types/project.lua index 15ecf3c..81399ea 100644 --- a/lua/neotest-java/types/project.lua +++ b/lua/neotest-java/types/project.lua @@ -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 @@ -42,7 +43,7 @@ function Project:get_modules() ---@type table 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 diff --git a/lua/neotest-java/util/write_file.lua b/lua/neotest-java/util/write_file.lua index 49de5b6..a41732a 100644 --- a/lua/neotest-java/util/write_file.lua +++ b/lua/neotest-java/util/write_file.lua @@ -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)