Last active
June 24, 2023 18:41
-
-
Save adityadroid/4647ffed2de93b60029b2d7cafea4610 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Function to copy and modify the run configuration files | |
copy_run_configs() { | |
local app_name="$1" | |
local source_dir="./apps/$app_name/.idea/runConfigurations" | |
local destination_dir="./.idea/runConfigurations" | |
# Create destination directory if it doesn't exist | |
mkdir -p "$destination_dir" | |
# Copy files and modify their content | |
for file in "$source_dir"/*; do | |
if [[ -f "$file" ]]; then | |
local filename=$(basename "$file") | |
local modified_filename="flutter_run_${app_name}_${filename}" | |
local existing_content=$(cat "$file") | |
local modified_content=$(echo "$existing_content" | sed -e "s|<option name=\"filePath\" value=\"\$PROJECT_DIR\$/|<option name=\"filePath\" value=\"\$PROJECT_DIR\$/apps/$app_name/|g" \ | |
-e "s|<configuration default=\"false\" name=\"|<configuration default=\"false\" name=\"$app_name -\> |g") | |
echo "$modified_content" > "$destination_dir/$modified_filename" | |
fi | |
done | |
} | |
# Recursively process app folders | |
process_apps() { | |
local apps_dir="./apps" | |
# Loop through all app folders | |
for app in "$apps_dir"/*; do | |
if [[ -d "$app" ]]; then | |
local app_name=$(basename "$app") | |
copy_run_configs "$app_name" | |
fi | |
done | |
} | |
# Call the function to start the process | |
process_apps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment