2013-03-18 16:48:50 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2013-03-21 10:50:13 +00:00
|
|
|
set -e
|
|
|
|
|
2013-03-18 16:48:50 +00:00
|
|
|
cat <<EOF
|
|
|
|
package blob
|
|
|
|
var files = map [string] map [string] []byte {
|
|
|
|
EOF
|
|
|
|
|
2013-03-21 10:50:13 +00:00
|
|
|
ORIGINAL_PWD=${PWD}
|
|
|
|
|
2013-03-18 16:48:50 +00:00
|
|
|
for dir in $@
|
|
|
|
do
|
2015-03-05 13:26:19 +00:00
|
|
|
cd "${dir}" > /dev/null
|
2013-03-21 10:50:13 +00:00
|
|
|
echo "\"$(basename ${dir})\": {"
|
2013-03-18 16:48:50 +00:00
|
|
|
|
2015-01-26 14:10:27 +00:00
|
|
|
# Do not embed map files and the non-minified bootstrap files.
|
2015-02-02 11:37:39 +00:00
|
|
|
# TODO(beorn7): There should be a better solution than hardcoding the
|
|
|
|
# exclusion here. We might want to switch to a less makeshift way of
|
|
|
|
# embedding files into the binary anyway...
|
2015-01-26 14:10:27 +00:00
|
|
|
find . -type f \! -name \*.map \! -name bootstrap.js \! -name bootstrap-theme.css \! -name bootstrap.css | while read file
|
2013-03-18 16:48:50 +00:00
|
|
|
do
|
2013-03-21 10:50:13 +00:00
|
|
|
name=$(echo "${file}"|sed 's|\.\/||')
|
2015-02-16 13:44:28 +00:00
|
|
|
# Using printf here instead of "echo -n" because the latter doesn't work on Mac OS X:
|
|
|
|
# http://hints.macworld.com/article.php?story=20071106192548833.
|
|
|
|
printf "\"$name\": []byte(\""
|
|
|
|
# The second newline deletion at the end is required for Mac OS X as well,
|
|
|
|
# as sed outputs a trailing newline there.
|
|
|
|
gzip -9 -c "${file}" | xxd -p | tr -d '\n' | sed 's/\(..\)/\\x\1/g' | tr -d '\n'
|
2015-02-13 13:46:20 +00:00
|
|
|
echo "\"),"
|
2013-03-18 16:48:50 +00:00
|
|
|
echo
|
|
|
|
done
|
2013-03-20 11:31:42 +00:00
|
|
|
echo "},"
|
2013-03-21 10:50:13 +00:00
|
|
|
cd "${ORIGINAL_PWD}"
|
2013-03-18 16:48:50 +00:00
|
|
|
done
|
|
|
|
echo '}'
|