Skip to content

Commit 5d2bbfe

Browse files
committed
Handle empty file case correctly
1 parent 8097863 commit 5d2bbfe

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

input_files/update_yml_entries.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ GITHUB_ENV=${GITHUB_ENV-/dev/null}
1616
command_wo_sub="{\"$component_name\": {\"Category\":\"$category\", \"Channel\": \"$channel\", \"Date\": \"$created_at\"}}"
1717
command_w_sub="{\"$component_name\": {\"Category\":\"$category\", \"Sub-category\":\"$subcategory\", \"Channel\": \"$channel\", \"Date\": \"$created_at\"}}"
1818

19-
if ! [ -f "$filename" ]; then
19+
empty_file=$(yq "." $filename)
20+
if ! [ -f "$filename" ] || [ -z "$empty_file" ]; then
2021
touch $filename
2122
if [ -z "$subcategory" ]; then
2223
yq -n -i -y "$command_wo_sub" $filename

0 commit comments

Comments
 (0)