Created
April 25, 2016 14:14
-
-
Save domderen/fe3e329568b57d2380a88f93e89aa44f to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
JS_FILES_LOCATION_PATTERN=$1 | |
VERSION=$2 | |
ATATUS_API_KEY=$3 | |
URL=$4 | |
ATATUS_CORRECT_RESPONSE="Upload successful!" | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
for f in $JS_FILES_LOCATION_PATTERN | |
do | |
echo "Processing file ${f}" | |
MAP_FILE="${f%.js}.map" | |
JS_FILE_NAME=$(basename $f) | |
JS_FILE_URL="${URL}/${VERSION}/${JS_FILE_NAME}" | |
echo "Map file for this file is ${MAP_FILE}" | |
echo "Filename is: ${JS_FILE_NAME}" | |
echo "File URL is: ${JS_FILE_URL}" | |
if [[ -e $MAP_FILE ]]; then | |
echo "Pushing file: ${f} with map file: ${MAP_FILE} into ATATUS" | |
ATATUS_RESPONSE=$(curl https://api.atatus.com/api/browser/sourcemap \ | |
-H "Authorization: token ${ATATUS_API_KEY}" \ | |
-F url=${JS_FILE_URL} \ | |
-F sourcemap=@${MAP_FILE}) | |
if [[ $ATATUS_RESPONSE != $ATATUS_CORRECT_RESPONSE ]]; then | |
echo "Incorrect response for Atatus: ${ATATUS_RESPONSE} expected: ${ATATUS_CORRECT_RESPONSE}. Aborting!" | |
exit 1 | |
else | |
echo "File pushed" | |
fi | |
else | |
echo "Did not found the map file ${MAP_FILE} for file ${f}. Aborting!" | |
exit 1 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment