fef8806867bedfd3dc95136c3d34f7a1307e2ba2
- Author
- Michael Aquilina <michaelaquilina@gmail.com>
- Committer
- GitHub <noreply@github.com>
- Date
Message
Merge pull request #62 from MichaelAquilina/project_detection
Display message when a python project is detected
Diff
1diff --git a/autoswitch_virtualenv.plugin.zsh b/autoswitch_virtualenv.plugin.zsh
2index dbb9e389d1428adbd298f30b31ffb79086db5bf1..51d49c8d7bbeb8a2eb57cd56f328f6ab5c095da8 100644
3--- a/autoswitch_virtualenv.plugin.zsh
4+++ b/autoswitch_virtualenv.plugin.zsh
5@@ -105,6 +105,9 @@ function check_venv()
6 else
7 SWITCH_TO="$(<"$venv_path")"
8 fi
9+ elif [[ -f "$PWD/requirements.txt" ]]; then
10+ printf "Python project detected. "
11+ printf "Run ${PURPLE}mkvenv${NORMAL} to setup autoswitching\n"
12 fi
13
14 if [[ -n "$SWITCH_TO" ]]; then
15diff --git a/tests/test_check_venv.zunit b/tests/test_check_venv.zunit
16index 79a858695882a6742fe28a3afecf1c41731ababa..cab07d2dd4be4a56c416c2677685454327ea6eaf 100644
17--- a/tests/test_check_venv.zunit
18+++ b/tests/test_check_venv.zunit
19@@ -25,6 +25,16 @@
20 rm -rf Pipfile
21 }
22
23+@test 'check_venv - Displays message on project detection' {
24+ PWD="$TARGET"
25+ touch "$TARGET/requirements.txt"
26+
27+ run check_venv
28+
29+ assert $status equals 0
30+ assert "$output" same_as "Python project detected. Run \e[35mmkvenv\e[0m to setup autoswitching"
31+}
32+
33
34 @test 'check_venv - Security warning for weak writeable by group permissions' {
35 PWD="$TARGET"