Skip to content

Commit 38e1c6b

Browse files
committed
safety check for empty deploy_directory
closes #5
1 parent e0caac7 commit 38e1c6b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

deploy.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ while : ; do
1919
elif [[ $1 = "-s" || $1 = "--setup" ]]; then
2020
setup=true
2121
shift
22+
elif [[ $1 = "-e" || $1 = "--allow-empty" ]]; then
23+
allow_empty=true
24+
shift
2225
else
2326
break
2427
fi
@@ -87,6 +90,11 @@ if [ ! -d "$deploy_directory" ]; then
8790
exit 1
8891
fi
8992

93+
if [[ -z `ls -A "$deploy_directory" 2> /dev/null` && -z $allow_empty ]]; then
94+
echo "Deploy directory '$deploy_directory' is empty. Aborting. If you're sure you want to deploy an empty tree, use the -e flag." >&2
95+
exit 1
96+
fi
97+
9098
disable_expanded_output
9199
git fetch --force $repo $deploy_branch:$deploy_branch
92100
enable_expanded_output

0 commit comments

Comments
 (0)