Add gem_env helper function to get gem env as json
This commit is contained in:
parent
1a1b1d9a15
commit
37bf538f12
@ -27,6 +27,26 @@ go_deps() (
|
|||||||
awk 'NR>'"${START_AT}"' && NR<'"${END_AT}"' {print $1}' "${GO_MOD}"
|
awk 'NR>'"${START_AT}"' && NR<'"${END_AT}"' {print $1}' "${GO_MOD}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#{{ if lookPath "gem" -}}
|
||||||
|
#{{ if lookPath "dasel" -}}
|
||||||
|
#{{ if lookPath "jq" -}}
|
||||||
|
gem_env () (
|
||||||
|
NAME=${1:-}
|
||||||
|
if [ "$NAME" != '' ]; then
|
||||||
|
gem environment \
|
||||||
|
| dasel --read yaml --write json \
|
||||||
|
| jq '.["RubyGems Environment"] | to_entries | map((.value | keys)[0] as $key | {key: $key, value: .value[$key] }) | from_entries' \
|
||||||
|
| jq --raw-output '.["'"${NAME}"'"]'
|
||||||
|
else
|
||||||
|
gem environment \
|
||||||
|
| dasel --read yaml --write json \
|
||||||
|
| jq '.["RubyGems Environment"] | to_entries | map((.value | keys)[0] as $key | {key: $key, value: .value[$key] }) | from_entries'
|
||||||
|
fi
|
||||||
|
)
|
||||||
|
#{{- end }}
|
||||||
|
#{{- end }}
|
||||||
|
#{{- end }}
|
||||||
|
|
||||||
make_script() (
|
make_script() (
|
||||||
cat <<-EOF > "${1}"
|
cat <<-EOF > "${1}"
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|||||||
@ -23,5 +23,13 @@ _add_path () {
|
|||||||
_add_path "/usr/local/opt/mysql-client/bin"
|
_add_path "/usr/local/opt/mysql-client/bin"
|
||||||
_add_path "${HOME}/google-cloud-sdk/bin"
|
_add_path "${HOME}/google-cloud-sdk/bin"
|
||||||
|
|
||||||
|
#{{ if lookPath "gem" -}}
|
||||||
|
#{{ if lookPath "dasel" -}}
|
||||||
|
#{{ if lookPath "jq" -}}
|
||||||
|
_add_path "$(gem_env "USER INSTALLATION DIRECTORY")/bin"
|
||||||
|
#{{- end }}
|
||||||
|
#{{- end }}
|
||||||
|
#{{- end }}
|
||||||
|
|
||||||
unset _add_path
|
unset _add_path
|
||||||
#{{- end }}
|
#{{- end }}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user