Skip to content

Commit

Permalink
Check for app existence in commands (plushu/plusku#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartpb committed Aug 20, 2014
1 parent 0a4e923 commit 9e87dc2
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 2 deletions.
7 changes: 7 additions & 0 deletions command
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ else
fi

app_dir=$PLUSHU_ROOT/apps/$app

# Check if app exists
if [[ ! -d "$app_dir" ]]; then
echo "App not found: $app" >&2
exit 1
fi

domain_file=$app_dir/domains

[[ -f "$domain_file" ]] && cat "$domain_file"
9 changes: 8 additions & 1 deletion subcommands/add
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ else
exit 1
fi

domains="${@:2}"
app_dir=$PLUSHU_ROOT/apps/$app

# Check if app exists
if [[ ! -d "$app_dir" ]]; then
echo "App not found: $app" >&2
exit 1
fi

domains="${@:2}"
domain_file=$app_dir/domains

for domain in "${domains[@]}"; do
Expand Down
8 changes: 8 additions & 0 deletions subcommands/all
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@ else
exit 1
fi

app_dir=$PLUSHU_ROOT/apps/$app

# Check if app exists
if [[ ! -d "$app_dir" ]]; then
echo "App not found: $app" >&2
exit 1
fi

"$PLUSHU_ROOT/lib/plushook" app-domains "$app"
8 changes: 8 additions & 0 deletions subcommands/clear
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ else
fi

app_dir=$PLUSHU_ROOT/apps/$app

# Check if app exists
if [[ ! -d "$app_dir" ]]; then
echo "App not found: $app" >&2
exit 1
fi

domain_file=$app_dir/domains

if [[ -n "$2" ]]; then
Expand All @@ -20,4 +27,5 @@ if [[ -n "$2" ]]; then
fi

rm -f "$domain_file"

"$PLUSHU_ROOT/lib/plushook" deploy-app "$app"
8 changes: 8 additions & 0 deletions subcommands/link
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ else
exit 1
fi

app_dir=$PLUSHU_ROOT/apps/$app

# Check if app exists
if [[ ! -d "$app_dir" ]]; then
echo "App not found: $app" >&2
exit 1
fi

path=`sed 's/&/\&/g' <<<"/${2#/}"`

"$PLUSHU_ROOT/lib/plushook" app-domains "$app" | sed "s ^.*\$ http://&$path"
9 changes: 8 additions & 1 deletion subcommands/remove
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ else
exit 1
fi

domains="${@:2}"
app_dir=$PLUSHU_ROOT/apps/$app

# Check if app exists
if [[ ! -d "$app_dir" ]]; then
echo "App not found: $app" >&2
exit 1
fi

domains="${@:2}"
domain_file=$app_dir/domains

fsed () {
Expand Down

0 comments on commit 9e87dc2

Please sign in to comment.