2017-06-17 02:11:54 +07:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-06-28 20:57:58 +07:00
|
|
|
set -e
|
|
|
|
|
2017-06-17 03:21:12 +07:00
|
|
|
NPM_UNPACK_DIR=/tmp/npm-unpack
|
2017-06-17 02:11:54 +07:00
|
|
|
|
2017-06-17 03:21:12 +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"`
|
2017-06-17 03:21:12 +07:00
|
|
|
echo "--- Authelia package is ${AUTHELIA_PACKAGE}"
|
2017-06-17 02:11:54 +07:00
|
|
|
|
2017-06-17 03:21:12 +07:00
|
|
|
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}
|
|
|
|
|
2017-06-17 03:21:12 +07:00
|
|
|
echo "--- Test unpacking..."
|
2017-06-17 02:11:54 +07:00
|
|
|
npm install ${AUTHELIA_PACKAGE}
|
|
|
|
|
2017-06-17 03:21:12 +07:00
|
|
|
RET_CODE_INSTALL=$?
|
2017-06-17 02:11:54 +07:00
|
|
|
# echo ${RET_CODE}
|
|
|
|
|
2017-06-17 03:21:12 +07:00
|
|
|
# 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
|
|
|
|
|
2017-06-17 03:21:12 +07:00
|
|
|
if [ "$RET_CODE_INSTALL" != "0" ] || [ "$RET_CODE_RUN" != "0" ]
|
2017-06-17 02:11:54 +07:00
|
|
|
then
|
2017-06-17 03:21:12 +07:00
|
|
|
echo "--- Unpacking failed..."
|
2017-06-17 02:11:54 +07:00
|
|
|
exit 1
|
|
|
|
else
|
2017-06-17 03:21:12 +07:00
|
|
|
echo "+++ Unpacking succeeded"
|
2017-06-17 02:11:54 +07:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|