Created
April 24, 2018 14:26
-
-
Save mvisonneau/3bb27436d1b6a4cfe36cbed5b518c9f0 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
#!/usr/bin/env bash | |
if ! [ -x "$(command -v git)" ]; then | |
echo 'Error: jq is not installed.' >&2 | |
exit 1 | |
fi | |
if [ -z "$1" ]; then | |
echo "Error: you must pass the filename as an argument" | |
exit 1 | |
else | |
FILE=$1 | |
fi | |
if [ ! -f ${FILE} ]; then | |
echo "Error: file ${FILE} does not exist" | |
exit 1 | |
fi | |
# Build JSON output using JQ | |
jq -n --arg data "$(<${FILE})" '{"data":$data}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment