#!/usr/bin/env bash

# Start in the right folder.
root_dir="$(dirname "${BASH_SOURCE[0]}")/.."
cd "$root_dir"

# Output.
echo 'Starting full build...'

# Run through full build flow.
./tools/clean &&
./tools/svg-optimize &&
# Disabling this for now until we figure out the proper place for it.
# ./tools/svg-to-php &&
./tools/svg-to-sprite &&
./tools/svg-to-font.js &&
./tools/svg-to-react-data.js &&
./tools/build-react &&
echo 'Build complete.' ||
echo 'Build failure!'

if [[ $1 == '--prod' ]]; then
	echo 'Checking for changed source files...'
	if ! git diff --exit-code --stat './src'; then
		echo 'Production builds should not change the ./src folder!'
		echo 'Did you forget to commit changes to ./src/react/social-logo-data.jsx?'
		exit 1
	fi
	echo 'Build is clean.'
fi
