#!/bin/sh

if [ -z $NODEJS ]
then
    if command -v nodejs > /dev/null; then NODEJS=$(command -v nodejs); else NODEJS=$(command -v node); fi
fi

export BASEDIR="$(dirname "$(dirname "$(readlink "$0" || echo "$0")")")"

[ -f local.conf ] && . ./local.conf

if command -v $NODEJS > /dev/null; then
    export NPMBINDIR="$($(dirname $NODEJS)/npm -g bin)"
else
    echo "node binary '$NODEJS' not found in path. You need to install node and have it in your path. '$PATH'"
    exit 1
fi

if [ -f $NPMBINDIR/grunt ];
then
    $NPMBINDIR/grunt "$@"
else
    echo "grunt binary '$NPMBINDIR/grunt' not found in path. Consider installing it with 'npm install -g grunt-cli'"
    exit 1
fi
