summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-03-03 00:51:11 +0800
committerruki <[email protected]>2023-03-03 00:51:11 +0800
commite4f1765e6a7b6365bc03912630353e96964f3719 (patch)
tree3c7f36cfb0fc67bfd09e0ef45346298947d24b9e
parentd469035fc49b6565a2ba7366d148d7f239bc352e (diff)
improve update
-rw-r--r--xmake/actions/update/main.lua17
1 files changed, 11 insertions, 6 deletions
diff --git a/xmake/actions/update/main.lua b/xmake/actions/update/main.lua
index 2413e7644..b7561365d 100644
--- a/xmake/actions/update/main.lua
+++ b/xmake/actions/update/main.lua
@@ -291,13 +291,13 @@ end
-- initialize shells
function _initialize_shell()
- local target, command, profile
+ local target, command
if is_host("windows") then
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()
- profile = path.join(os.programdir(), "scripts", "profile-win.ps1")
+ local profile = path.join(os.programdir(), "scripts", "profile-win.ps1")
command = format("if (Test-Path -Path \"%s\" -PathType Leaf) {\n . \"%s\"\n}", profile, profile)
else
raise("failed to get profile location from powershell!")
@@ -309,9 +309,13 @@ function _initialize_shell()
elseif shell:endswith("zsh") then target = "~/.zshrc"
elseif shell:endswith("ksh") then target = "~/.kshrc"
end
- profile = path.join(os.programdir(), "scripts", "profile-unix.sh")
- command = format("export XMAKE_ROOTDIR=\"%s\"\nexport PATH=\"$XMAKE_ROOTDIR:$PATH\"\n", path.directory(os.programfile()))
- command = command .. format("[[ -s \"%s\" ]] && source \"%s\"", profile, profile)
+ command = "[[ -s \"$HOME/.xmake/profile\" ]] && source \"$HOME/.xmake/profile\""
+
+ -- write home profile
+ local profile = path.join(os.programdir(), "scripts", "profile-unix.sh")
+ local bridge_command = format("export XMAKE_ROOTDIR=\"%s\"\nexport PATH=\"$XMAKE_ROOTDIR:$PATH\"\n", path.directory(os.programfile()))
+ bridge_command = bridge_command .. format("[[ -s \"%s\" ]] && source \"%s\"\n", profile, profile)
+ io.writefile("~/.xmake/profile", bridge_command)
end
-- trace
@@ -328,7 +332,7 @@ function _initialize_shell()
file = file .. "\n"
end
end
- file = file .. "# >>> xmake >>>\n" .. command .. "\n# <<< xmake <<<"
+ file = file .. "# >>> xmake >>>\n" .. command .. "\n# <<< xmake <<<\n"
io.writefile(target, file)
return true
end,
@@ -516,3 +520,4 @@ function main()
_install(sourcedir)
end
end
+