This commit is contained in:
Your Name 2024-07-25 18:11:27 -04:00
parent faf818cebe
commit b7c595f8fd
2 changed files with 24 additions and 13 deletions

View File

@ -5,13 +5,13 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
exit 1 exit 1
fi fi
# Function to generate SHA-256 hashes for .sh files in a given directory # Function to generate SHA-256 hashes for .sh files in src or dist directories
generate_sha256_hashes() { release_hash() {
local src_dir="$1" local base_dir="$1"
# Check if the directory exists # Check if the base directory exists
if [ ! -d "$src_dir" ]; then if [ ! -d "$base_dir" ]; then
echo "Directory $src_dir does not exist." echo "Base directory $base_dir does not exist."
return 1 return 1
fi fi
@ -21,14 +21,25 @@ generate_sha256_hashes() {
hash_cmd="sha256sum" hash_cmd="sha256sum"
fi fi
# Loop through all .sh files in the directory # Function to process a directory
for file in "$src_dir"/*.sh; do process_directory() {
local dir="$1"
for file in "$dir"/*.sh; do
# Skip if no .sh files are found # Skip if no .sh files are found
[ -e "$file" ] || continue [ -e "$file" ] || continue
# Calculate the SHA-256 hash and save it to a .sha256 file # Calculate the SHA-256 hash and save it to a .sha256 file
$hash_cmd "$file" | awk '{ print $1 }' > "$file.sha256" $hash_cmd "$file" | awk '{ print $1 }' > "$file.sha256"
done done
}
# Process src and dist directories if they exist
for sub_dir in src dist; do
local full_dir="$base_dir/$sub_dir"
if [ -d "$full_dir" ]; then
process_directory "$full_dir"
fi
done
echo "SHA-256 hashes have been saved in .sha256 files." echo "SHA-256 hashes have been saved in .sha256 files."
} }

View File

@ -1 +1 @@
7846925456f82da2e475833061a4ee605302d3db001d0df8c1678d71e9329896 f5c7f474e279c603a166b3b908f345ff9f8de879e8d39595f6ee95bccc123c5b