Skip to content

Instantly share code, notes, and snippets.

@domderen
Created April 25, 2016 14:14
Show Gist options
  • Save domderen/fe3e329568b57d2380a88f93e89aa44f to your computer and use it in GitHub Desktop.
Save domderen/fe3e329568b57d2380a88f93e89aa44f to your computer and use it in GitHub Desktop.
#!/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