@@ -29,23 +29,33 @@ function build_sdk {
2929 mv firebase-functions-* .tgz integration_test/functions/firebase-functions.tgz
3030}
3131
32+ function pick_node6 {
33+ cd $DIR
34+ cp package.node6.json functions/package.json
35+ }
36+
37+ function pick_node8 {
38+ cd $DIR
39+ cp package.node8.json functions/package.json
40+ }
41+
3242function install_deps {
3343 announce " Installing dependencies..."
3444 cd $DIR /functions
45+ rm -rf node_modules/firebase-functions
3546 npm install
3647}
3748
3849function delete_all_functions {
39- announce " Deploying empty index.js to project..."
50+ announce " Deleting all functions in project..."
4051 cd $DIR
41- ./functions/node_modules/.bin/tsc -p functions/ # Make sure the functions/lib directory actually exists.
42- echo " " > functions/lib/index.js
43- firebase deploy --project=$PROJECT_ID --only functions
52+ # Try to delete, if there are errors it is because the project is already empty,
53+ # in that case do nothing.
54+ firebase functions:delete callableTests createUserTests databaseTests deleteUserTests firestoreTests integrationTests pubsubTests --project=$PROJECT_ID -f || :
4455 announce " Project emptied."
4556}
4657
4758function deploy {
48- announce " Deploying functions..."
4959 cd $DIR
5060 ./functions/node_modules/.bin/tsc -p functions/
5161 # Deploy functions, and security rules for database and Firestore
@@ -72,16 +82,20 @@ function cleanup {
7282 announce " Performing cleanup..."
7383 delete_all_functions
7484 rm $DIR /functions/firebase-functions.tgz
85+ rm $DIR /functions/package.json
7586 rm -f $DIR /functions/firebase-debug.log
7687 rm -rf $DIR /functions/node_modules/firebase-functions
7788}
7889
7990build_sdk
91+ pick_node8
8092install_deps
8193delete_all_functions
94+ announce " Deploying functions to Node 8 runtime ..."
8295deploy
8396run_tests
84- announce " Re-deploying the same functions to make sure updates work..."
97+ pick_node6
98+ announce " Re-deploying the same functions to Node 6 runtime ..."
8599deploy
86100run_tests
87101cleanup
0 commit comments