Skip to content

Commit 0890133

Browse files
authored
Handle missing example files gracefully (#1950)
1 parent be48754 commit 0890133

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

install/_lib.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,18 @@ fi
4141
# A couple of the config files are referenced from other subscripts, so they
4242
# get vars, while multiple subscripts call ensure_file_from_example.
4343
function ensure_file_from_example {
44-
if [[ -f "$1" ]]; then
45-
echo "$1 already exists, skipped creation."
44+
target="$1"
45+
if [[ -f "$target" ]]; then
46+
echo "$target already exists, skipped creation."
4647
else
47-
echo "Creating $1..."
48-
cp -n $(echo "$1" | sed 's/\.[^.]*$/.example&/') "$1"
4948
# sed from https://stackoverflow.com/a/25123013/90297
49+
example="$(echo "$target" | sed 's/\.[^.]*$/.example&/')"
50+
if [[ ! -f "$example" ]]; then
51+
echo "Oops! Where did $example go? 🤨 We need it in order to create $target."
52+
exit
53+
fi
54+
echo "Creating $target ..."
55+
cp -n "$example" "$target"
5056
fi
5157
}
5258
SENTRY_CONFIG_PY='../sentry/sentry.conf.py'

0 commit comments

Comments
 (0)