File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 1
-
2
- #! /bin/bash
3
-
1
+ #! /bin/bash
4
2
# Ensure the 'tree' command is installed
5
3
if ! command -v tree & > /dev/null; then
6
4
echo " 'tree' command not found. Please install it to use this script."
@@ -45,9 +43,12 @@ echo '## Project Directory Structure' >> "$readme_file"
45
43
echo ' ```' >> " $readme_file "
46
44
47
45
# Generate the directory structure and append to README.md, ignoring certain files
48
- tree -I ' LICENSE|create-readme.sh|.github|.git' --charset utf-8 >> " $readme_file "
49
-
50
- # End the Markdown code block
46
+ IGNORED_FILES=" LICENSE|create-readme.sh|.github|.git"
47
+ if ! tree_output=$( tree -I " $IGNORED_FILES " -n --dirsfirst --charset utf-8 2> /dev/null) ; then
48
+ echo " Error: Failed to generate directory structure."
49
+ exit 1
50
+ fi
51
+ echo " $tree_output " >> " $readme_file "
51
52
echo ' ```' >> " $readme_file "
52
53
53
54
# Print success message
You can’t perform that action at this time.
0 commit comments