build.sh: Add error reporting+failing

This commit is contained in:
Haelwenn (lanodan) Monnier 2019-04-13 09:25:23 +02:00
parent 641996c7ba
commit 69f0029a9a
No known key found for this signature in database
GPG key ID: D5B7A8E43C997DEE
2 changed files with 16 additions and 12 deletions

View file

@ -1,3 +1,7 @@
Based on 2c2f649200ba5b742ba9d17ac5ba553c752b59aa 2019-05-04T10:40:32
Note: This file is to be cleared after each rebase on upstream
Additions
---------
- `build.sh`: Add error reporting+failing

View file

@ -2,19 +2,19 @@
TARGET="${TARGET:-../pleroma}" # Where pleromas repository is sitting
static_dir="priv/static" # Set this to instance/static when testing production build
if [[ ! -d "${TARGET}/${static_dir}" ]]
then
echo "Error: ${TARGET}/${static_dir} directory is missing, are you sure TARGET is set to a pleroma repository?"
echo "Info: TARGET=${TARGET}"
die() {
echo "Die: $@"
exit 1
fi
}
yarn install -D
[ -d "${TARGET}/priv/static" ] || die "${TARGET}/priv/static directory is missing, are you sure TARGET is set to a pleroma repository? (Info: TARGET=${TARGET} )"
yarn install -D || die "Installing dependencies via yarn failed"
rm -rf public/packs public/assets
env -i "PATH=$PATH" npm run build
cp public/assets/sw.js "${TARGET}/${static_dir}/sw.js"
rm -rf "${TARGET}/${static_dir}/packs"
cp -r public/packs "${TARGET}/${static_dir}/packs"
rm -rf "${TARGET}/${static_dir}/emoji/*.svg"
cp -r public/emoji/* "${TARGET}/${static_dir}/emoji"
env -i "PATH=$PATH" npm run build || die "Building the frontend failed"
cp public/assets/sw.js "${TARGET}/${static_dir}/sw.js" || || die "installing sw.js (service-worker) failed"
rm -rf "${TARGET}/${static_dir}/packs" || die "Removing old assets in priv/static/packs failed"
cp -r public/packs "${TARGET}/${static_dir}/packs" || die "Copying new assets in priv/static/packs failed"
rm -rf "${TARGET}/${static_dir}/emoji/*.svg" || die "Removing the old emoji assets failed"
cp -r public/emoji/* "${TARGET}/${static_dir}/emoji" || die "Installing the new emoji assets failed"