diff options
| author | xq114 <[email protected]> | 2022-02-15 15:19:43 +0800 |
|---|---|---|
| committer | xq114 <[email protected]> | 2022-02-15 15:19:43 +0800 |
| commit | b1c67cc18b7cb658a258d027ecf026fdf3a4f2cd (patch) | |
| tree | b59246b1e8e127358ad904d0f2166c0faad611dd /xmake/actions/update/main.lua | |
| parent | 21b2aab7fe9f0564a3bd31365bb5accc5b075940 (diff) | |
improve to find powershell
Diffstat (limited to 'xmake/actions/update/main.lua')
| -rw-r--r-- | xmake/actions/update/main.lua | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/xmake/actions/update/main.lua b/xmake/actions/update/main.lua index 59fe40d36..8d4f4b582 100644 --- a/xmake/actions/update/main.lua +++ b/xmake/actions/update/main.lua @@ -113,9 +113,12 @@ function _uninstall() if is_host("windows") then for _, shell in ipairs({"pwsh", "powershell"}) do for _, type in ipairs({"AllUsersAllHosts", "CurrentUserAllHosts", "CurrentUserCurrentHost"}) do - local outdata, errdata = os.iorunv(shell, {"-c", "Write-Output $PROFILE." .. type}) - if outdata then - table.insert(profiles, outdata:trim()) + local psshell = find_tool(shell) + if psshell then + local outdata, errdata = try {function () return os.iorunv(shell, {"-c", "Write-Output $PROFILE." .. type}) end} + if outdata then + table.insert(profiles, outdata:trim()) + end end end end @@ -287,9 +290,8 @@ function _initialize_shell() local target, command, profile if is_host("windows") then - local pwsh = find_tool("pwsh") - local psshell = pwsh and "pwsh" or "powershell" - local outdata, errdata = os.iorunv(psshell, {"-c", "Write-Output $PROFILE.CurrentUserAllHosts"}) + local psshell = find_tool("pwsh") or find_tool("powershell") + local outdata, errdata = try {function () return os.iorunv(psshell.program, {"-c", "Write-Output $PROFILE.CurrentUserAllHosts"}) end} if outdata then target = outdata:trim() command = "if (Test-Path -Path \"%s\" -PathType Leaf) {\n . \"%s\"\n}" |
