2121# applications.
2222
2323set -e
24+ set -u
2425
2526if [ -z " $1 " ]; then
2627 echo " [ERROR] No package name provided."
27- echo " [INFO] Usage: ./verifyReleaseTarball .sh <PACKAGE_NAME>"
28+ echo " [INFO] Usage: ./verify_package .sh <PACKAGE_NAME>"
2829 exit 1
2930fi
3031
31- # Variables
3232PKG_NAME=" $1 "
33- ROOT=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
34- MOCHA_CLI=" $ROOT /node_modules/.bin/mocha -r ts-node/register"
35- DIR=" $ROOT /test/integration/typescript"
36- WORK_DIR=` mktemp -d`
37-
38- if [ ! -f " $ROOT /$PKG_NAME " ]; then
39- echo " Package $PKG_NAME does not exist."
33+ if [ ! -f " ${PKG_NAME} " ]; then
34+ echo " Package ${PKG_NAME} does not exist."
4035 exit 1
4136fi
4237
43- # check if tmp dir was created
44- if [[ ! " $WORK_DIR " || ! -d " $WORK_DIR " ]]; then
38+ # create a temporary directory
39+ WORK_DIR=` mktemp -d`
40+ if [[ ! " ${WORK_DIR} " || ! -d " ${WORK_DIR} " ]]; then
4541 echo " Could not create temp dir"
4642 exit 1
4743fi
4844
4945# deletes the temp directory
50- function cleanup {
51- rm -rf " $WORK_DIR "
52- echo " Deleted temp working directory $WORK_DIR "
46+ function cleanup {
47+ rm -rf " ${ WORK_DIR} "
48+ echo " Deleted temp working directory ${ WORK_DIR} "
5349}
5450
5551# register the cleanup function to be called on the EXIT signal
5652trap cleanup EXIT
5753
58- # Enter work dir
59- pushd " $WORK_DIR "
54+ # Copy package and test sources into working directory
55+ cp " ${PKG_NAME} " " ${WORK_DIR} "
56+ cp -r test/integration/typescript/* " ${WORK_DIR} "
57+ cp test/resources/mock.key.json " ${WORK_DIR} "
6058
61- # Copy test sources into working directory
62- cp -r $DIR /* .
63- cp " $ROOT /test/resources/mock.key.json" .
59+ # Enter work dir
60+ pushd " ${WORK_DIR} "
6461
6562# Install the test package
6663npm install
6764
6865# Install firebase-admin package
69- npm install -S " $ROOT / $ PKG_NAME"
66+ npm install -S " ${ PKG_NAME} "
7067
7168echo " > tsc -p tsconfig.json"
72- $ROOT /node_modules/.bin/tsc -p tsconfig.json
69+ . /node_modules/.bin/tsc -p tsconfig.json
7370
71+ MOCHA_CLI=" ./node_modules/.bin/mocha -r ts-node/register"
7472echo " > $MOCHA_CLI src/*.test.ts"
75- $MOCHA_CLI src/* .test.ts
73+ $MOCHA_CLI src/* .test.ts
0 commit comments