Created
January 29, 2024 22:39
-
-
Save amazingandyyy/39641e672b27a85952affff425009a4c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
merge_config_json() { | |
local src=$1 | |
local target=$2 | |
local temp_file | |
temp_file=$(mktemp) | |
if [[ -f "$target" ]]; then | |
jq -s '.[0] * .[1]' "$src" "$target" > "$temp_file" && mv "$temp_file" "$target" | |
else | |
# If target does not exist, override it with source | |
cp "$src" "$target" | |
fi | |
rm -f "$temp_file" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment