summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-03-17 22:50:37 +0800
committerruki <[email protected]>2023-03-17 22:50:37 +0800
commit7cb489300326c7c6b83c7787ed2f8d6d909b4666 (patch)
tree80ae712fea5197a4c95bae2e7ad1e5a31057c871
parent879f532bca3c8b56c7a2979c0246ca9ae2a909c2 (diff)
fix find powershell
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/find_program.lua2
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/find_programver.lua2
-rw-r--r--xmake/modules/detect/tools/find_powershell.lua11
-rw-r--r--xmake/modules/detect/tools/find_pwsh.lua11
4 files changed, 8 insertions, 18 deletions
diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
index 90dd963fb..2bb04697e 100644
--- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
+++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
@@ -61,6 +61,8 @@ function sandbox_lib_detect_find_program._do_check(program, opt)
local errors = nil
if type(opt.check) == "string" then
ok, errors = os.runv(program, {opt.check}, {envs = opt.envs})
+ elseif type(opt.check) == "table" then
+ ok, errors = os.runv(program, opt.check, {envs = opt.envs})
else
ok, errors = sandbox.load(opt.check, program)
end
diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua b/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua
index 24e6b97e0..376b11005 100644
--- a/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua
+++ b/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua
@@ -89,6 +89,8 @@ function sandbox_lib_detect_find_programver.main(program, opt)
if not ok and outdata and option.get("diagnosis") then
utils.cprint("${color.warning}checkinfo: ${clear dim}" .. outdata)
end
+ elseif type(command) == "table" then
+ ok, outdata = os.iorunv(program, command, {envs = opt.envs})
else
ok, outdata = os.iorunv(program, {command or "--version"}, {envs = opt.envs})
end
diff --git a/xmake/modules/detect/tools/find_powershell.lua b/xmake/modules/detect/tools/find_powershell.lua
index 78cb35afd..d8e1d9ec8 100644
--- a/xmake/modules/detect/tools/find_powershell.lua
+++ b/xmake/modules/detect/tools/find_powershell.lua
@@ -35,20 +35,13 @@ import("lib.detect.find_programver")
-- @endcode
--
function main(opt)
-
- -- init options
opt = opt or {}
- opt.command = opt.command or "--version"
-
- -- find program
+ opt.check = opt.check or {"-c", "$PSVersionTable"}
local program = find_program(opt.program or "powershell", opt)
-
- -- find program version
local version = nil
if program and opt and opt.version then
+ opt.command = opt.command or {"-c", "$PSVersionTable"}
version = find_programver(program, opt)
end
-
- -- ok?
return program, version
end
diff --git a/xmake/modules/detect/tools/find_pwsh.lua b/xmake/modules/detect/tools/find_pwsh.lua
index 4b42ad8bf..d13efec2c 100644
--- a/xmake/modules/detect/tools/find_pwsh.lua
+++ b/xmake/modules/detect/tools/find_pwsh.lua
@@ -35,20 +35,13 @@ import("lib.detect.find_programver")
-- @endcode
--
function main(opt)
-
- -- init options
opt = opt or {}
- opt.command = opt.command or "--version"
-
- -- find program
+ opt.check = opt.check or {"-c", "$PSVersionTable"}
local program = find_program(opt.program or "pwsh", opt)
-
- -- find program version
local version = nil
if program and opt and opt.version then
+ opt.command = opt.command or {"-c", "$PSVersionTable"}
version = find_programver(program, opt)
end
-
- -- ok?
return program, version
end