#!/usr/bin/env sh

IS_PUBLISHED_VERSION=`git describe --tags --exact-match 2>/dev/null`
WS_GRUNT_VERSION=`cat package.json | grep '"version"' | sed -E -e 's/.*"version": "([^"]*)",/\1/'`

# We don't set the version suffix on tagged (published) builds
if [ -n "$TRAVIS_BUILD_NUMBER" -a -z "$IS_PUBLISHED_VERSION" ]; then
    WS_GRUNT_VERSION="$WS_GRUNT_VERSION-beta.$TRAVIS_BUILD_NUMBER"
fi

npm install
WS_GRUNT_VERSION=$WS_GRUNT_VERSION grunt "$@"
