Skip to content

Commit

Permalink
chore[test]: use uv.os_uname() to check OS sysname if avail
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaozg committed Jul 2, 2023
1 parent ab6883e commit f9e999d
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions lib/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,24 @@ else
usecolors = false
end

if _G.jit and _G.jit.os then
-- Luajit provides explicit platform detection
utils.isWindows = _G.jit.os == "Windows"
utils.isLinux = _G.jit.os == 'Linux'
if (uv.os_uname) then
local uname = assert(uv.os_uname())
utils.isWindows = uname.sysname == "Windows"
utils.isLinux = uname.sysname == 'Linux'
else
-- Normal lua will only have \ for path separator on windows.
utils.isWindows = package.config:find("\\") and true or false
local f = io.popen('uname', 'r')
if f then
local line = f:read("*l")
utils.isLinux = line == 'Linux'
f:close()
if _G.jit and _G.jit.os then
-- Luajit provides explicit platform detection
utils.isWindows = _G.jit.os == "Windows"
utils.isLinux = _G.jit.os == 'Linux'
else
-- Normal lua will only have \ for path separator on windows.
utils.isWindows = package.config:find("\\") and true or false
if not utils.isWindows then
local _os = os.getenv('RUNNER_OS') or os.getenv('OSTYPE')
if (_os and _os:lower():match('linux')) then
utils.isLinux = true
end
end
end
end

Expand Down

0 comments on commit f9e999d

Please sign in to comment.