authelia/scripts/npm-deployment-test.sh

44 lines
841 B
Bash
Raw Normal View History

2017-06-17 02:11:54 +07:00
#!/bin/bash
set -e
NPM_UNPACK_DIR=/tmp/npm-unpack
2017-06-17 02:11:54 +07:00
echo "--- Packing npm package into a tarball"
2017-06-17 02:11:54 +07:00
npm pack
AUTHELIA_PACKAGE=`ls | grep "authelia-\([0-9]\+.\)\{2\}[0-9]\+.tgz"`
echo "--- Authelia package is ${AUTHELIA_PACKAGE}"
2017-06-17 02:11:54 +07:00
2017-09-09 04:06:25 +07:00
tar -tzvf ${AUTHELIA_PACKAGE}
echo "--- Copy package into "${NPM_UNPACK_DIR}" to test unpacking"
2017-06-17 02:11:54 +07:00
mkdir -p ${NPM_UNPACK_DIR}
cp ${AUTHELIA_PACKAGE} ${NPM_UNPACK_DIR}
pushd ${NPM_UNPACK_DIR}
echo "--- Test unpacking..."
2017-06-17 02:11:54 +07:00
npm install ${AUTHELIA_PACKAGE}
RET_CODE_INSTALL=$?
2017-06-17 02:11:54 +07:00
# echo ${RET_CODE}
# The binary must start and display the help menu
./node_modules/.bin/authelia | grep "No config file has been provided."
RET_CODE_RUN=$?
2017-06-17 02:11:54 +07:00
popd
if [ "$RET_CODE_INSTALL" != "0" ] || [ "$RET_CODE_RUN" != "0" ]
2017-06-17 02:11:54 +07:00
then
echo "--- Unpacking failed..."
2017-06-17 02:11:54 +07:00
exit 1
else
echo "+++ Unpacking succeeded"
2017-06-17 02:11:54 +07:00
exit 0
fi