Merge branch 'local-whitespace-fix'

This commit is contained in:
Stratus3D 2016-08-18 13:43:13 -04:00
commit c007ac728b
2 changed files with 15 additions and 3 deletions

View File

@ -18,10 +18,10 @@ version_command() {
check_if_plugin_exists $plugin
check_if_version_exists $plugin $version
if [ -f $file ] && grep $plugin $file > /dev/null; then
sed -i -e "s/$plugin .*/$plugin $version/" $file
if [ -f "$file" ] && grep $plugin "$file" > /dev/null; then
sed -i -e "s/$plugin .*/$plugin $version/" "$file"
else
echo "$plugin $version" >> $file
echo "$plugin $version" >> "$file"
fi
}

View File

@ -45,6 +45,18 @@ teardown() {
[ "$(cat $PROJECT_DIR/.tool-versions)" = "dummy 1.1.0" ]
}
@test "local should create a local .tool-versions file if it doesn't exist when the directory name contains whitespace" {
WHITESPACE_DIR="$PROJECT_DIR/whitespace\ dir"
mkdir -p "$WHITESPACE_DIR"
cd "$WHITESPACE_DIR"
run local_command "dummy" "1.1.0"
tool_version_contents=$(cat "$WHITESPACE_DIR/.tool-versions")
[ "$status" -eq 0 ]
[ "$tool_version_contents" = "dummy 1.1.0" ]
}
@test "local should overwrite the existing version if it's set" {
echo 'dummy 1.0.0' >> $PROJECT_DIR/.tool-versions
run local_command "dummy" "1.1.0"