Last active
January 3, 2016 22:29
-
-
Save mattbierner/8529020 to your computer and use it in GitHub Desktop.
khepri git hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
KHEPRI="khepri" | |
OPTIONS="" | |
SRC=lib | |
DEST=dist | |
DEST_NODE=dist_node | |
function _compile { | |
local file=$1 | |
local path=${file##*/} | |
local out=$2 | |
$KHEPRI -o $out $1 $3 | |
OUT=$? | |
if [ $OUT -ne 0 ]; then | |
exit 1 | |
fi | |
git add $out | |
} | |
for file in $(git diff --cached --name-only --diff-filter=ACM) | |
do | |
if [[ $file =~ $SRC/.+\.kep ]]; | |
then | |
# AMD | |
path="${DEST}${file#$SRC}" | |
out="${path%.kep}.js" | |
_compile $file $out "" | |
# NODE | |
path_node="${DEST_NODE}${file#$SRC}" | |
out_node="${path_node%.kep}.js" | |
_compile $file $out_node "--package_manager=node" | |
fi | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment