#!/bin/bash

#
# The purpose of this script is to run wdio while returning
# a exit code 0 even on failure which in turn makes sure that
# npm doesn't print this useless extra error after the wdio
# already printed the real error:
#
#     npm ERR! code ELIFECYCLE
#     npm ERR! errno 1
#     npm ERR! quizmaster@0.0.1 test-e2e: `npm run -s test-e2e-raw`
#     npm ERR! Exit status 1
#     npm ERR!
#     npm ERR! Failed at the quizmaster@0.0.1 test-e2e script.
#     npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
#
#     npm ERR! A complete log of this run can be found in:
#     npm ERR!     /home/molsson/.npm/_logs/2017-07-21T11_57_48_384Z-debug.log
#
# Of course, it's still important to get a non-zero exitcode
# when running CI environments, and we don't want to append
# "|| true" to the actual command in package.json because then
# you can't do stuff like "npm run foo -- --other-param".
#
# For a discussion around the useless npm error, see:
# https://github.com/npm/npm/issues/6124
#

SCRIPT_DIR="$(dirname $0)"
$SCRIPT_DIR/../node_modules/.bin/wdio wdio.conf.js "$@"
exit 0
