Skip to content

Instantly share code, notes, and snippets.

@villander
Last active December 11, 2018 23:39
Show Gist options
  • Select an option

  • Save villander/4ca0458a2cf64efae4361a2ef62e539f to your computer and use it in GitHub Desktop.

Select an option

Save villander/4ca0458a2cf64efae4361a2ef62e539f to your computer and use it in GitHub Desktop.
#!/bin/sh
URL_BASE="https://my.example.com"
basename="web-app"
for js in dist/assets/*.map; do
# $js has the full path. Chop it down to just the file name.
filename=$(basename ${js})
# Production requires a little more work because of Ember CLI's fingerprinting.
# First, remove the ember-generated fingerprint and .js extension. This prefix is common between JS and MAP file.
# linux
# filebase=$(expr match "$filename" '\(.*-\)')
# osx
filebase=$(expr "${filename}" : '\(.*-\)')
# Find the map file with this prefix. We take extra care to make sure it's simply the prefix + fingerprint + .map.
# Without this additional logic, spike-airbrake.map and spike-frontend-airbrake.map would both match while handling
# spike-1234.js
# mapfile=$(find dist/assets -regex "dist/assets/${filebase}[0-9a-f]+\.map")
# osx
mapfile=$(find -E dist/assets -iregex "dist/assets/${filebase}[0-9a-f]+\.map")
if [ -e ${mapfile} ]; then
echo "Uploading js/map files to Airbrake: ${filename}, ${mapfile}"
curl https://airbrake.io/api/v4/projects/${AIRBRAKE_PROJECT_ID}/sourcemaps \
-X POST \
-H "Authorization: Bearer ${AIRBRAKE_PROJECT_KEY}" \
-F file=@${mapfile} \
-F name=${URL_BASE}/assets/${filename}
if [ -e ${mapfile} ] ; then
# rm ${mapfile}
# osx
rm -rf ${mapfile}
echo '';
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment