From fc5eb491eef6ddc0d72f014abe13ca6c0e65af11 Mon Sep 17 00:00:00 2001 From: Nameless Date: Tue, 25 Jun 2024 08:27:41 -0500 Subject: [PATCH] improve os checks in luvi libraries --- src/lua/luvibundle.lua | 5 ++--- src/lua/luvipath.lua | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/lua/luvibundle.lua b/src/lua/luvibundle.lua index e62afe5a..46ca9be8 100644 --- a/src/lua/luvibundle.lua +++ b/src/lua/luvibundle.lua @@ -6,10 +6,9 @@ local pathJoin = luviPath.pathJoin local getenv = require('os').getenv local loadstring = loadstring or load -local unpack = unpack or _G.table.unpack +local unpack = unpack or table.unpack -local tmpBase = luviPath.isWindows and (getenv("TMP") or uv.cwd()) or - (getenv("TMPDIR") or '/tmp') +local tmpBase = getenv("TMPDIR") or getenv("TMP") or getenv("TEMP") or (uv.fs_access("/tmp", "r") and "/tmp") or uv.cwd() -- Bundle from folder on disk local function folderBundle(base) diff --git a/src/lua/luvipath.lua b/src/lua/luvipath.lua index 598fee52..73814f32 100644 --- a/src/lua/luvipath.lua +++ b/src/lua/luvipath.lua @@ -2,10 +2,10 @@ local luvi = require('luvi') local getPrefix, splitPath, joinParts local isWindows -if _G.jit then - isWindows = _G.jit.os == "Windows" +if pcall(require, 'jit') then + isWindows = require('jit').os == "Windows" else - isWindows = not not package.path:match("\\") + isWindows = not not (package.config:sub(1, 1) == "\\" or package.path:find("\\", 1, true) or package.cpath:find("\\", 1, true)) end if isWindows then