From 8d30fc5bd2b352897b81756400ab50d2be859209 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Tue, 5 Mar 2024 22:13:12 -0300 Subject: fix(windows): output native slashes on fs.find --- src/luarocks/build/builtin.lua | 7 ++++--- src/luarocks/fs/win32/tools.lua | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index c55b61a0..4c15d2bf 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua @@ -8,6 +8,7 @@ local builtin = {} builtin.skip_lua_inc_lib_check = true local unpack = unpack or table.unpack +local dir_sep = package.config:sub(1, 1) local fs = require("luarocks.fs") local path = require("luarocks.path") @@ -59,7 +60,7 @@ do for _, parent in ipairs({"src", "lua", "lib"}) do if fs.is_dir(parent) then fs.change_dir(parent) - prefix = parent.."/" + prefix = parent .. dir_sep break end end @@ -69,7 +70,7 @@ do if not skiplist[base] then local luamod = file:match("(.*)%.lua$") if luamod then - modules[path.path_to_module(file)] = prefix..file + modules[path.path_to_module(file)] = prefix .. file else local cmod = file:match("(.*)%.c$") if cmod then @@ -89,7 +90,7 @@ do fs.pop_dir() end - local bindir = (fs.is_dir("src/bin") and "src/bin") + local bindir = (fs.is_dir(dir.path("src", "bin")) and dir.path("src", "bin")) or (fs.is_dir("bin") and "bin") if bindir then install = { bin = {} } diff --git a/src/luarocks/fs/win32/tools.lua b/src/luarocks/fs/win32/tools.lua index be63063b..86cbb45b 100644 --- a/src/luarocks/fs/win32/tools.lua +++ b/src/luarocks/fs/win32/tools.lua @@ -10,6 +10,8 @@ local cfg = require("luarocks.core.cfg") local vars = setmetatable({}, { __index = function(_,k) return cfg.variables[k] end }) +local dir_sep = package.config:sub(1, 1) + --- Adds prefix to command to make it run from a directory. -- @param directory string: Path to a directory. -- @param cmd string: A command-line string. @@ -132,7 +134,7 @@ function tools.find(at) local first_two = file:sub(1,2) if first_two == ".\\" or first_two == "./" then file=file:sub(3) end if file ~= "." then - table.insert(result, (file:gsub("\\", "/"))) + table.insert(result, (file:gsub("[\\/]", dir_sep))) end end pipe:close() -- cgit v1.2.3-55-g6feb