From 3cbf475dae8a815284fa8c36a0d35846619770eb Mon Sep 17 00:00:00 2001 From: Arbaaz Laskar Date: Tue, 16 Aug 2022 18:05:27 +0530 Subject: [PATCH] fix: install command was overwriting the env if it already exists --- .version | 2 +- README.md | 2 +- bin/pyenv-win-venv.ps1 | 11 ++++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.version b/.version index 44bb5d1..f7abe27 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -0.4.1 \ No newline at end of file +0.4.2 \ No newline at end of file diff --git a/README.md b/README.md index 32ec77c..2d7104e 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ Invoke-WebRequest -UseBasicParsing -Uri "https://raw.githubusercontent.com/pyenv ``` > pyenv-win-venv - pyenv-win-venv v0.4.1 + pyenv-win-venv v0.4.2 Copyright (c) Arbaaz Laskar Usage: pyenv-win-venv diff --git a/bin/pyenv-win-venv.ps1 b/bin/pyenv-win-venv.ps1 index a2eddbe..2300aa2 100644 --- a/bin/pyenv-win-venv.ps1 +++ b/bin/pyenv-win-venv.ps1 @@ -64,9 +64,14 @@ function main { elseif ($subcommand1 -eq "install") { if (test-path -PathType container "$pyenv_versions_dir\$subcommand2") { if ($subcommand3 -ne "self") { - Write-Host "Installing env: $subcommand3 using Python v$subcommand2" - pyenv shell $subcommand2 - python -m venv "$app_env_dir\$subcommand3" + if (!(test-path -PathType container "$app_env_dir\$subcommand3")) { + Write-Host "Installing env: $subcommand3 using Python v$subcommand2" + pyenv shell $subcommand2 + python -m venv "$app_env_dir\$subcommand3" + } + else { + Write-Host "`"$subcommand3`" already exists. Please choose another name for the env." + } } else { Write-Host "Cannot create an env called `"self`" since while uninstalling pyenv-venv uninstall self is already a pre-existing command!"