2016-04-27 17:21:12 +05:00
|
|
|
#!/usr/bin/env bash
|
2016-07-03 02:30:03 +05:00
|
|
|
root=$(readlink -e "$(dirname "$0")")
|
2016-05-03 21:16:36 +05:00
|
|
|
set -e
|
|
|
|
if [ "x" == "x$root" ] ; then
|
|
|
|
root=$PWD/${0##*}
|
|
|
|
fi
|
2016-07-03 02:30:03 +05:00
|
|
|
cd "$root"
|
2016-05-03 21:16:36 +05:00
|
|
|
|
2016-04-27 17:21:12 +05:00
|
|
|
if [ -z "$GOPATH" ]; then
|
2016-05-03 21:16:36 +05:00
|
|
|
export GOPATH=$root/go
|
2016-07-03 02:30:03 +05:00
|
|
|
mkdir -p "$GOPATH"
|
2016-04-27 17:21:12 +05:00
|
|
|
fi
|
|
|
|
|
2016-07-03 02:30:03 +05:00
|
|
|
if [ ! -f "$GOPATH/bin/minify" ]; then
|
|
|
|
echo "set up minifiy"
|
2016-04-30 17:26:14 +05:00
|
|
|
go get -v github.com/tdewolff/minify/cmd/minify
|
2016-04-27 17:21:12 +05:00
|
|
|
fi
|
2016-07-03 02:30:03 +05:00
|
|
|
if [ ! -f "$GOPATH/bin/gopherjs" ]; then
|
2016-05-18 22:16:06 +05:00
|
|
|
echo "set up gopherjs"
|
|
|
|
go get -v -u github.com/gopherjs/gopherjs
|
|
|
|
fi
|
|
|
|
|
|
|
|
# build cuckoo miner
|
|
|
|
echo "Building cuckoo miner"
|
|
|
|
go get -v -u github.com/ZiRo-/cuckgo/miner_js
|
2016-07-03 02:30:03 +05:00
|
|
|
"$GOPATH/bin/gopherjs" -m -v build github.com/ZiRo-/cuckgo/miner_js
|
2016-05-18 22:16:06 +05:00
|
|
|
mv ./miner_js.js ./contrib/static/miner-js.js
|
|
|
|
rm ./miner_js.js.map
|
|
|
|
|
2016-05-03 21:16:36 +05:00
|
|
|
outfile=$PWD/contrib/static/nntpchan.js
|
2016-04-27 17:21:12 +05:00
|
|
|
|
2016-04-30 21:25:15 +05:00
|
|
|
lint() {
|
|
|
|
if [ "x$(which jslint)" == "x" ] ; then
|
|
|
|
# no jslint
|
|
|
|
true
|
|
|
|
else
|
|
|
|
echo "jslint: $1"
|
2016-07-03 02:30:03 +05:00
|
|
|
jslint --browser "$1"
|
2016-04-30 21:25:15 +05:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-04-30 18:58:21 +05:00
|
|
|
mini() {
|
|
|
|
echo "minify $1"
|
|
|
|
echo "" >> $2
|
2016-05-03 23:58:57 +05:00
|
|
|
echo "/* local file: $1 */" >> $2
|
2016-07-03 02:30:03 +05:00
|
|
|
"$GOPATH/bin/minify" --mime=text/javascript >> $2 < $1
|
2016-04-30 18:58:21 +05:00
|
|
|
}
|
2016-04-27 17:21:12 +05:00
|
|
|
|
2016-04-30 21:25:15 +05:00
|
|
|
# do linting too
|
|
|
|
if [ "x$1" == "xlint" ] ; then
|
|
|
|
echo "linting..."
|
|
|
|
for f in ./contrib/js/*.js ; do
|
2016-07-03 02:30:03 +05:00
|
|
|
lint "$f"
|
2016-04-30 21:25:15 +05:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2016-04-30 18:58:21 +05:00
|
|
|
echo -e "//For source code and license information please check https://github.com/majestrate/nntpchan \n" > $outfile
|
|
|
|
|
2016-05-03 23:58:57 +05:00
|
|
|
if [ -e ./contrib/js/contrib/*.js ] ; then
|
|
|
|
for f in ./contrib/js/contrib/*.js ; do
|
2016-07-03 02:30:03 +05:00
|
|
|
mini "$f" "$outfile"
|
2016-05-03 23:58:57 +05:00
|
|
|
done
|
|
|
|
fi
|
2016-07-03 02:30:03 +05:00
|
|
|
|
|
|
|
mini ./contrib/js/main.js_ "$outfile"
|
2016-04-30 18:58:21 +05:00
|
|
|
|
|
|
|
# local js
|
2016-04-27 17:21:12 +05:00
|
|
|
for f in ./contrib/js/*.js ; do
|
2016-07-03 02:30:03 +05:00
|
|
|
mini "$f" "$outfile"
|
2016-04-27 17:21:12 +05:00
|
|
|
done
|
2016-04-30 17:26:14 +05:00
|
|
|
echo "ok"
|