Skip to content

Commit f050c21

Browse files
committed
Added some output checks before creating file. #27 jenv use remove from cmd is now working
1 parent 4c7ce1d commit f050c21

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

jenv.bat

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ if exist jenv.path.tmp (
3434

3535
if exist jenv.use.tmp (
3636
FOR /F "tokens=* delims=" %%x in (jenv.use.tmp) DO (
37-
set JENVUSE=%%x
37+
if "%%x" == "remove" (
38+
set "JENVUSE="
39+
) ELSE (
40+
set JENVUSE=%%x
41+
)
42+
3843
)
44+
3945
del -f jenv.use.tmp
4046
)

src/jenv-use.psm1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ function Invoke-Use {
1717
# Remove the local JEnv
1818
if ($name -eq "remove") {
1919
$Env:JENVUSE = $null # Set for powershell users
20-
Set-Content -path "jenv.use.tmp" -value $null # Create temp file so no restart of the active shell is required
20+
if ($output) {
21+
Set-Content -path "jenv.use.tmp" -value "remove" # Create temp file so no restart of the active shell is required
22+
}
2123
Write-Host Your session JEnv was unset
2224
return
2325
}

src/jenv.ps1

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,12 @@ if ($javaPaths.Length -gt 0) {
6363
catch [System.Management.Automation.MethodInvocationException] {
6464
Write-Host JEnv wants to change your system environment vars. Therefore you need to restart it with administration rights. This should only once be required. If you dont want to, you have to call JEnv on every terminal opening to change your session vars
6565
}
66-
catch {
67-
Write-Host fuck
68-
}
69-
7066
$path = $userPath + ";" + $systemPath
7167

7268
$Env:PATH = $path # Set for powershell users
73-
Set-Content -path "jenv.path.tmp" -value $path # Create temp file so no restart of the active shell is required
69+
if ($output) {
70+
Set-Content -path "jenv.path.tmp" -value $path # Create temp file so no restart of the active shell is required
71+
}
7472
}
7573
#endregion
7674

0 commit comments

Comments
 (0)