#!/bin/sh

COVERFILE=packagecover.out

if [ ! -f "$COVERFILE" ]; then
	echo "ERROR: coverfile missing!" >&2
	echo "  - Either the coverfile [$COVERFILE] was not generated yet or"
	echo "    the tests were run without coverage enabled."
	echo "  - This script can not continue without the coverfile."
	exit 1
fi

if [ -n "$COVERALLS_TOKEN" ] ; then
    # Send to coveralls.io
    $HOME/gopath/bin/goveralls \
        -coverprofile=$COVERFILE \
        -service=travis-ci \
        -repotoken $COVERALLS_TOKEN
fi

# Clean up
rm -f $COVERFILE > /dev/null 2>&1
exit 0
