Improved check for components that are already enabled

pull/974/head
Nils Winkler 2017-05-10 11:12:07 +02:00
parent 56d0f56714
commit b1481038d8
2 changed files with 17 additions and 8 deletions

View File

@ -328,14 +328,11 @@ _enable-thing ()
plugin=$(basename $plugin) plugin=$(basename $plugin)
# Check for existence of the file using a wildcard, since we don't know which priority might have been used when enabling it. # Check for existence of the file using a wildcard, since we don't know which priority might have been used when enabling it.
for f in $BASH_IT/$subdirectory/enabled/*$BASH_IT_LOAD_PRIORITY_SEPARATOR$plugin; do typeset enabled_plugin=$(command ls $BASH_IT/$subdirectory/enabled/{[0-9]*$BASH_IT_LOAD_PRIORITY_SEPARATOR$plugin,$plugin} 2>/dev/null | head -1)
if [ -e "$f" ] ; then if [ ! -z "$enabled_plugin" ] ; then
printf '%s\n' "$file_entity is already enabled." printf '%s\n' "$file_entity is already enabled."
return return
fi fi
break
done
mkdir -p $BASH_IT/$subdirectory/enabled mkdir -p $BASH_IT/$subdirectory/enabled

View File

@ -70,6 +70,18 @@ function __setup_plugin_tests {
[ ! -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ] [ ! -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ]
} }
@test "enable the nvm plugin if it was enabled without a priority" {
__setup_plugin_tests
ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/nvm.plugin.bash
[ -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ]
run _enable-plugin "nvm"
[ "${lines[0]}" == 'nvm is already enabled.' ]
[ -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ]
[ ! -L "$BASH_IT/plugins/enabled/225---nvm.plugin.bash" ]
}
@test "enable the nvm plugin twice" { @test "enable the nvm plugin twice" {
__setup_plugin_tests __setup_plugin_tests