fetch-language-data.sh: Improve and made CWD-independent

This commit is contained in:
Niklas Laxström
2018-03-05 12:41:36 +01:00
committed by Kartik Mistry
parent 3707da24e0
commit 438c59cc65

View File

@@ -1,32 +1,33 @@
#!/bin/bash
BASEDIR=$(dirname "$0")
BASEDIR="$BASEDIR/.."
set -o errexit -o nounset -o pipefail
BASEDIR=$(dirname "$(dirname "$(readlink -f "$0")")")
DEST="$BASEDIR/src/"
CLONEDIR="$BASEDIR/vendor/language-data"
UPSTREAM="https://github.com/wikimedia/language-data.git"
echo "Getting latest language-data from $UPSTREAM"
if [ -d "$CLONEDIR" ]; then
pushd "$CLONEDIR"
if [ -d "$CLONEDIR" ]
then (
cd "$CLONEDIR"
git pull
popd
else
) else
git clone "$UPSTREAM" "$CLONEDIR"
fi
if [ -d "$BASEDIR"/node_modules/browserify ];then
if [ -d "$BASEDIR"/node_modules/browserify ]
then
echo "browserify already installed"
else
else (
echo "Installing browserify"
cd "$BASEDIR";
npm install browserify
fi
) fi
echo "Transforming language-data"
"$BASEDIR"/node_modules/browserify/bin/cmd.js "$CLONEDIR"/language-data.json -t "$BASEDIR"/scripts/transform.js -o "$DEST"/jquery.uls.data.js
echo "language-data wrote to $DEST/jquery.uls.data.js"
echo "Done."