21
21
# applications.
22
22
23
23
set -e
24
+ set -u
24
25
25
26
if [ -z " $1 " ]; then
26
27
echo " [ERROR] No package name provided."
27
- echo " [INFO] Usage: ./verifyReleaseTarball .sh <PACKAGE_NAME>"
28
+ echo " [INFO] Usage: ./verify_package .sh <PACKAGE_NAME>"
28
29
exit 1
29
30
fi
30
31
31
- # Variables
32
32
PKG_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."
40
35
exit 1
41
36
fi
42
37
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
45
41
echo " Could not create temp dir"
46
42
exit 1
47
43
fi
48
44
49
45
# 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} "
53
49
}
54
50
55
51
# register the cleanup function to be called on the EXIT signal
56
52
trap cleanup EXIT
57
53
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} "
60
58
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} "
64
61
65
62
# Install the test package
66
63
npm install
67
64
68
65
# Install firebase-admin package
69
- npm install -S " $ROOT / $ PKG_NAME"
66
+ npm install -S " ${ PKG_NAME} "
70
67
71
68
echo " > tsc -p tsconfig.json"
72
- $ROOT /node_modules/.bin/tsc -p tsconfig.json
69
+ . /node_modules/.bin/tsc -p tsconfig.json
73
70
71
+ MOCHA_CLI=" ./node_modules/.bin/mocha -r ts-node/register"
74
72
echo " > $MOCHA_CLI src/*.test.ts"
75
- $MOCHA_CLI src/* .test.ts
73
+ $MOCHA_CLI src/* .test.ts
0 commit comments