summaryrefslogtreecommitdiff
path: root/xmake/scripts
diff options
context:
space:
mode:
authorxq114 <[email protected]>2023-03-23 16:03:11 +0800
committerxq114 <[email protected]>2023-03-23 16:03:11 +0800
commitdf31f7516538cb4049110c89f290c7a398a58f3b (patch)
treeea2e9879d109e22bdfab602dfa367d309f464b71 /xmake/scripts
parent19c31069f6336cb969f9fefc059890f3cc64d2d8 (diff)
detect corrupt xmake.lua for virtual environment
Diffstat (limited to 'xmake/scripts')
-rw-r--r--xmake/scripts/virtualenvs/register-virtualenvs.sh11
-rw-r--r--xmake/scripts/xrepo-hook.psm16
2 files changed, 17 insertions, 0 deletions
diff --git a/xmake/scripts/virtualenvs/register-virtualenvs.sh b/xmake/scripts/virtualenvs/register-virtualenvs.sh
index e853a54ba..15ed63bcd 100644
--- a/xmake/scripts/virtualenvs/register-virtualenvs.sh
+++ b/xmake/scripts/virtualenvs/register-virtualenvs.sh
@@ -35,6 +35,11 @@ function xrepo {
unset XMAKE_PROMPT_BACKUP
unset XMAKE_ENV_BACKUP
fi
+ local currentTest="$("$XMAKE_EXE" lua --quiet private.xrepo.action.env)" || return 1
+ if [ ! -z "$currentTest" ]; then
+ echo "error: corrupt xmake.lua detected in the current directory!"
+ return 1
+ fi
"$XMAKE_EXE" lua private.xrepo.action.env.info config || return 1
local prompt="$("$XMAKE_EXE" lua --quiet private.xrepo.action.env.info prompt)" || return 1
if [ -z "${prompt+x}" ]; then
@@ -64,9 +69,15 @@ function xrepo {
unset XMAKE_PROMPT_BACKUP
unset XMAKE_ENV_BACKUP
fi
+ local currentTest="$("$XMAKE_EXE" lua --quiet private.xrepo.action.env)" || return 1
+ if [ ! -z "$currentTest" ]; then
+ echo "error: corrupt xmake.lua detected in the current directory!"
+ return 1
+ fi
"$XMAKE_EXE" lua private.xrepo.action.env.info config $bnd || return 1
local prompt="$("$XMAKE_EXE" lua --quiet private.xrepo.action.env.info prompt $bnd)" || return 1
if [ -z "${prompt+x}" ]; then
+ echo "error: invalid environment!"
return 1
fi
local activateCommand="$("$XMAKE_EXE" lua --quiet private.xrepo.action.env.info script.bash $bnd)" || return 1
diff --git a/xmake/scripts/xrepo-hook.psm1 b/xmake/scripts/xrepo-hook.psm1
index 8e09c85b9..b05557efa 100644
--- a/xmake/scripts/xrepo-hook.psm1
+++ b/xmake/scripts/xrepo-hook.psm1
@@ -15,6 +15,12 @@ function Enter-XrepoEnvironment {
);
begin {
+ $currentTest = (& $Env:XMAKE_EXE lua --quiet private.xrepo.action.env | Out-String);
+ if (-not $? -or $currentTest) {
+ Write-Host "error: corrupt xmake.lua detected in the current directory!";
+ Exit 1;
+ }
+
$script:xrepoOldEnvs = (Get-ChildItem -Path Env:);
if (-not $bnd) {