Skip to content

Commit

Permalink
fix(insert-description): Don't crash when file does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
parmentf committed Feb 6, 2024
1 parent 032f180 commit 4c1c231
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions bin/insert-description.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,23 @@ function insert_description() {
MARKDOWN_PATH=$1
SLASH_PATH=${MARKDOWN_PATH//_//}
INI_PATH=${SLASH_PATH/%.md/.ini}
echo "$INI_PATH"
echo "-----------"
printf " - %s" "$INI_PATH"

if [ ! -f "$INI_PATH" ]; then
printf " X\n"
return
fi

DESCRIPTION=$(markdown2line "$MARKDOWN_PATH")

CONTAINS_DESCRIPTION=$(grep "post.description" "$INI_PATH")

if [ "$CONTAINS_DESCRIPTION" = "" ]; then
sed -i "/^post\.summary.*/a \
post.description = $DESCRIPTION" "$INI_PATH"
else
sed -i "s/post.description =.*/post.description = $DESCRIPTION/" "$INI_PATH"
fi
printf " ✓\n"
}

for file in "$@"; do
Expand Down

0 comments on commit 4c1c231

Please sign in to comment.