Created
September 26, 2016 07:28
-
-
Save riston/f9d8cfc4522cc1e6118d8b1908abbfca to your computer and use it in GitHub Desktop.
Heroku NODE_CONFIG change
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
#!/bin/bash | |
# | |
# .config.sh application-name change the NODE_CONFIG value | |
set -euo pipefail | |
cd "$(dirname "$0")/.." | |
APPLICATION="${1:-}" | |
TMPFILE="$(mktemp /tmp/config.XXXX.json)" | |
# Check for application name | |
if [ "${APPLICATION}" == "" ]; then | |
echo "Make sure to set the heroku application argument!" | |
exit 1 | |
fi | |
if hash -v json &>/dev/null -eq 1; then | |
echo "Make sure the json tool is installed." | |
exit 1 | |
fi | |
if hash -v heroku &>/dev/null -eq 1; then | |
echo "Make sure the Heroku toolbelt is installed." | |
exit 1 | |
fi | |
echo "-> Edit app config ${APPLICATION}, create tmp file ${TMPFILE}" | |
heroku config:get NODE_CONFIG -a "${APPLICATION}" > "${TMPFILE}" | |
echo "-> Format the JSON input" | |
json -f "${TMPFILE}" --in-place | |
echo "-> Trigger editor with current config" | |
subl3 --wait "${TMPFILE}" | |
echo "-> Validate config" | |
cat "${TMPFILE}" | json --validate | |
CONFIG=$(cat "${TMPFILE}") | |
echo "-> Set new Heorku config value '${CONFIG}'" | |
heroku config:set NODE_CONFIG="${CONFIG}" -a "${APPLICATION}" | |
# Delete file after delete, if you want the file to remain after edit don't | |
# delete this | |
# rm "${TMPFILE}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment