diff --git a/tools/vecGeneratoe.sh b/tools/vecGeneratoe.sh index 4c6cf89..178436a 100644 --- a/tools/vecGeneratoe.sh +++ b/tools/vecGeneratoe.sh @@ -1,45 +1,76 @@ -#!/bin/bash +##!/bin/bash +# +# +## Relative path to the package +#PACKAGE_PATH="../packages/core" +# +## Get absolute path to the package +#SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +#PACKAGE_ABS_PATH="$SCRIPT_DIR/$PACKAGE_PATH" +# +#echo "๐Ÿ—ƒ๏ธ package path: $PACKAGE_ABS_PATH" +# +## Directory to read files from +#sourcePath="../assets/icons" +#targetPath="../assets/vec" +#echo "๐Ÿ—ƒ๏ธ sourcePath path: $sourcePath" +#echo "๐Ÿ—ƒ๏ธ targetPath path: $targetPath" +# +# +#if [ ! -e "$targetPath" ]; then +# echo "๐Ÿ“ Directory does not exist. Creating: $targetPath" +# mkdir -p "$targetPath" +#fi +# +# +## Loop and delete old vec file +#for file in "$targetPath"/* +#do +# if [ -f "$file" ]; then +# +# echo "Delete old ===> $file" +# rm "$file" +# fi +#done +## Loop through all files in the directory +#for file in "$sourcePath"/* +#do +# if [ -f "$file" ]; then +# echo "Generate Vec file ===> $file" +# fileName=$(basename -- "$file") +# echo "Generate Vec file ===> $fileName" +# dart run vector_graphics_compiler -i "$file" -o "$targetPath/$fileName.vec" +# git add . +# fi +#done -# Relative path to the package PACKAGE_PATH="../packages/core" - -# Get absolute path to the package SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" PACKAGE_ABS_PATH="$SCRIPT_DIR/$PACKAGE_PATH" echo "๐Ÿ—ƒ๏ธ package path: $PACKAGE_ABS_PATH" -# Directory to read files from sourcePath="../assets/icons" targetPath="../assets/vec" -echo "๐Ÿ—ƒ๏ธ sourcePath path: $sourcePath" -echo "๐Ÿ—ƒ๏ธ targetPath path: $targetPath" +echo "๐Ÿ—ƒ๏ธ sourcePath: $sourcePath" +echo "๐Ÿ—ƒ๏ธ targetPath: $targetPath" +mkdir -p "$targetPath" -if [ ! -e "$targetPath" ]; then - echo "๐Ÿ“ Directory does not exist. Creating: $targetPath" - mkdir -p "$targetPath" -fi +# Delete old .vec files +echo "๐Ÿงน Deleting old .vec files..." +find "$targetPath" -type f -name "*.vec" -exec rm {} \; +# Generate .vec files in parallel +echo "โš™๏ธ Generating .vec files in parallel..." -# Loop and delete old vec file -for file in "$targetPath"/* -do - if [ -f "$file" ]; then +find "$sourcePath" -type f | xargs -P 10 -I {} bash -c ' + input="{}" + filename=$(basename "$input") + output="'$targetPath'/$filename.vec" + echo "โžก๏ธ Generating: $filename" + dart run vector_graphics_compiler -i "$input" -o "$output" +' - echo "Delete old ===> $file" - rm "$file" - fi -done -# Loop through all files in the directory -for file in "$sourcePath"/* -do - if [ -f "$file" ]; then - echo "Generate Vec file ===> $file" - fileName=$(basename -- "$file") - echo "Generate Vec file ===> $fileName" - dart run vector_graphics_compiler -i "$file" -o "$targetPath/$fileName.vec" - git add . - fi -done \ No newline at end of file +git add .