From d3112113bd1a0ba9959d8db64fa1ebba0313b073 Mon Sep 17 00:00:00 2001 From: Jaehwa Noh Date: Tue, 18 Jun 2024 20:27:17 +0900 Subject: [PATCH] Add file existence, and check is blank, and reorder the create README.md. Change-Id: Ie2a039440143253b347495b46ae53b02d36d1c3d --- generateModuleGraphs.sh | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/generateModuleGraphs.sh b/generateModuleGraphs.sh index a503a1c00..fc2676cab 100755 --- a/generateModuleGraphs.sh +++ b/generateModuleGraphs.sh @@ -105,20 +105,30 @@ echo "$module_paths" | while read -r module_path; do file_name="dep_graph${module_path//:/_}" # Replace colons with underscores file_name="${file_name//-/_}" # Replace dashes with underscores - check_and_create_readme "$module_path" "$file_name" - # Generate the .gv file in a temporary location # .*//g' | tr -d '\0' | - xmllint --format - \ - > "docs/images/graphs/${file_name}.svg" - # Remove the temporary .gv file - rm "/tmp/${file_name}.gv" + # Check gv file's existence + if [ -e "/tmp/${file_name}.gv" ]; then + # Convert to SVG using dot, remove unnecessary comments + svg_cleared=`dot -Tsvg "/tmp/${file_name}.gv" | sed -e 's/.*//g' | tr -d '\0'` + + # Check file is empty or not, if not empty run xmllint to reformat + # Save as svg file + if [ -n "$svg_cleared" ]; then + echo $svg_cleared | xmllint --format - > "docs/images/graphs/${file_name}.svg" + else + echo $svg_cleared > "docs/images/graphs/${file_name}.svg" + fi + + # Create README.md + check_and_create_readme "$module_path" "$file_name" + + # Remove tmp files + rm "/tmp/${file_name}.gv" + fi fi done