Skip to content

Commit

Permalink
Handle empty file case correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
koplo199 committed Dec 18, 2022
1 parent 8097863 commit 5d2bbfe
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion input_files/update_yml_entries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ GITHUB_ENV=${GITHUB_ENV-/dev/null}
command_wo_sub="{\"$component_name\": {\"Category\":\"$category\", \"Channel\": \"$channel\", \"Date\": \"$created_at\"}}"
command_w_sub="{\"$component_name\": {\"Category\":\"$category\", \"Sub-category\":\"$subcategory\", \"Channel\": \"$channel\", \"Date\": \"$created_at\"}}"

if ! [ -f "$filename" ]; then
empty_file=$(yq "." $filename)
if ! [ -f "$filename" ] || [ -z "$empty_file" ]; then
touch $filename
if [ -z "$subcategory" ]; then
yq -n -i -y "$command_wo_sub" $filename
Expand Down

0 comments on commit 5d2bbfe

Please sign in to comment.