summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorxq114 <[email protected]>2021-04-30 22:21:10 +0800
committerxq114 <[email protected]>2021-04-30 22:21:10 +0800
commit947cfffa942ec1160a68c614c296830991fc0710 (patch)
tree8fae1934be0092be4fa36acec27b911677468420 /scripts
parent38b65439249e7de42e8a542a138ff90cccc54c37 (diff)
improve envrionment management without xmake cache
Diffstat (limited to 'scripts')
-rw-r--r--scripts/xrepo-hook.psm112
-rwxr-xr-xscripts/xrepo.bat13
2 files changed, 17 insertions, 8 deletions
diff --git a/scripts/xrepo-hook.psm1 b/scripts/xrepo-hook.psm1
index 22a726b97..efd3f909e 100644
--- a/scripts/xrepo-hook.psm1
+++ b/scripts/xrepo-hook.psm1
@@ -14,11 +14,17 @@ function Enter-XrepoEnvironment {
begin {
$script:xrepoOldEnvs = (Get-ChildItem -Path Env:);
+
+ & $Env:XMAKE_EXE config
+
+ $xmakeColorTermBackup, $Env:XMAKE_COLORTERM = $Env:XMAKE_COLORTERM, "nocolor";
$xrepoPrompt = (& $Env:XMAKE_EXE lua private.xrepo.action.env.info prompt | Out-String);
- if (-not $?) {
- Write-Host $xrepoPrompt
- Exit 1
+ $Env:XMAKE_COLORTERM = $xmakeColorTermBackup;
+ if (-not $xrepoPrompt.StartsWith("[")) {
+ Write-Host $xrepoPrompt;
+ Exit 1;
}
+
$activateCommand = (& $Env:XMAKE_EXE lua private.xrepo.action.env.info script.powershell | Out-String);
Write-Verbose "[xrepo env script.powershell]`n$activateCommand";
diff --git a/scripts/xrepo.bat b/scripts/xrepo.bat
index c1dde03fe..cbf7a080e 100755
--- a/scripts/xrepo.bat
+++ b/scripts/xrepo.bat
@@ -1,6 +1,5 @@
-@echo off
-
@set "XMAKE_EXE=xmake"
+
@if [%1]==[env] (
if [%2]==[quit] (
if defined XMAKE_PROMPT_BACKUP (
@@ -19,6 +18,7 @@
call %XMAKE_ENV_BACKUP%
setlocal EnableDelayedExpansion
if !errorlevel! neq 0 exit /B !errorlevel!
+ %XMAKE_EXE% config
@%XMAKE_EXE% lua private.xrepo.action.env.info prompt 1>nul
if !errorlevel! neq 0 (
echo error: xmake.lua not found^^!
@@ -32,17 +32,20 @@
exit /B 1
) else (
setlocal EnableDelayedExpansion
+ %XMAKE_EXE% config
@%XMAKE_EXE% lua private.xrepo.action.env.info prompt 1>nul
if !errorlevel! neq 0 (
echo error: xmake.lua not found^^!
exit /B !errorlevel!
)
endlocal
- for /f %%i in ('@%XMAKE_EXE% lua private.xrepo.action.env.info prompt') do @set "PROMPT=%%i %PROMPT%"
- set XMAKE_PROMPT_BACKUP=%PROMPT%
+ for /f %%i in ('@%XMAKE_EXE% lua private.xrepo.action.env.info prompt') do @(
+ @set "PROMPT=%%i %PROMPT%"
+ )
+ @set XMAKE_PROMPT_BACKUP=%PROMPT%
)
for /f %%i in ('@%XMAKE_EXE% lua private.xrepo.action.env.info envfile') do @(
- set "XMAKE_ENV_BACKUP=%%i.bat"
+ @set "XMAKE_ENV_BACKUP=%%i.bat"
@"%XMAKE_EXE%" lua private.xrepo.action.env.info backup.cmd 1>"%%i.bat"
)
for /f %%i in ('@%XMAKE_EXE% lua private.xrepo.action.env.info envfile') do @(