Created
September 25, 2024 10:37
-
-
Save hassaku63/a9b40cfbaf641ede229ef0a8edca3699 to your computer and use it in GitHub Desktop.
Expand dotenv to JSON array of name/value object (like ECS task-def)
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
# blog(jp): https://zenn.dev/hassaku63/articles/b026266e5a82b4 | |
alias jq-dotenv="jq -R 'split(\"\n\") | map(split(\"=\")) | flatten | {\"name\": .[0], \"value\": .[1]}'" | |
function dotenv-to-json () { | |
filename=$1 | |
grep -v '^\s*#' ${filename} |grep -v '^\s*$' | \ | |
jq -R 'split("\n") | map(split("=")) | flatten | {"name": .[0], "value": .[1]}' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
example usage