2016-08-10 21:36:11 +02:00
|
|
|
set -e
|
|
|
|
|
2016-07-07 23:23:18 +02:00
|
|
|
# Get against which ref to diff
|
|
|
|
if git rev-parse --verify HEAD >/dev/null 2>&1
|
|
|
|
then
|
|
|
|
against=HEAD
|
|
|
|
else
|
2016-08-10 21:36:11 +02:00
|
|
|
# Something weird, initial commit
|
2016-07-28 23:57:29 +02:00
|
|
|
exit 1
|
2016-07-07 23:23:18 +02:00
|
|
|
fi
|
|
|
|
|
2016-08-10 21:36:11 +02:00
|
|
|
# List all the modified CSS and JS files (not in output path)
|
2016-08-04 15:28:07 +02:00
|
|
|
css_js_files=$(git diff-index --name-only $against | grep -e '.\(jsx\?\)\|\(s\?css\)$' | grep -v "^public")
|
2016-07-07 23:23:18 +02:00
|
|
|
|
|
|
|
# Nothing more to do if no JS files was committed
|
2016-07-30 00:48:41 +02:00
|
|
|
if [ -z "$css_js_files" ]
|
2016-07-07 23:23:18 +02:00
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2016-08-10 21:36:11 +02:00
|
|
|
# Else, rebuild as production, run tests and add files
|
2016-07-07 23:23:18 +02:00
|
|
|
echo "Rebuilding dist JavaScript files…"
|
2016-08-10 21:36:11 +02:00
|
|
|
npm test
|
2016-07-29 23:57:21 +02:00
|
|
|
npm run clean
|
2016-07-30 19:50:04 +02:00
|
|
|
npm run build:prod
|
2016-08-04 15:28:07 +02:00
|
|
|
git add public
|