From 381c733c0b0f1df7fe7bb4811c0eb1a191b00b27 Mon Sep 17 00:00:00 2001
From: Diana Tkachenko <31747099+thechenky@users.noreply.github.com>
Date: Thu, 1 Aug 2019 15:16:48 -0700
Subject: [PATCH] Fix sed command that breaks on linux (#545)

* fix sed command that breaks on linux

* fixing rm error
---
 integration_test/run_tests.sh | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/integration_test/run_tests.sh b/integration_test/run_tests.sh
index 765e3b0d7..903936b13 100755
--- a/integration_test/run_tests.sh
+++ b/integration_test/run_tests.sh
@@ -41,13 +41,19 @@ function build_sdk {
 function pick_node8 {
   cd "${DIR}"
   cp package.node8.json functions/package.json
-  sed -i '' "s/firebase-functions.tgz/firebase-functions-${TIMESTAMP}.tgz/g" functions/package.json
+  # we have to do the -e flag here so that it work both on linux and mac os, but that creates an extra
+  # backup file called package.json-e that we should clean up afterwards.
+  sed -i -e "s/firebase-functions.tgz/firebase-functions-${TIMESTAMP}.tgz/g" functions/package.json
+  rm -f functions/package.json-e
 }
 
 function pick_node10 {
   cd "${DIR}"
   cp package.node10.json functions/package.json
-  sed -i '' "s/firebase-functions.tgz/firebase-functions-${TIMESTAMP}.tgz/g" functions/package.json
+  # we have to do the -e flag here so that it work both on linux and mac os, but that creates an extra
+  # backup file called package.json-e that we should clean up afterwards.
+  sed -i -e "s/firebase-functions.tgz/firebase-functions-${TIMESTAMP}.tgz/g" functions/package.json
+  rm -f functions/package.json-e
 }
 
 function install_deps {
@@ -101,7 +107,7 @@ function run_tests {
 function cleanup {
   announce "Performing cleanup..."
   delete_all_functions
-  rm "${DIR}/functions/firebase-functions-*.tgz"
+  rm "${DIR}/functions/firebase-functions-${TIMESTAMP}.tgz"
   rm "${DIR}/functions/package.json"
   rm -f "${DIR}/functions/firebase-debug.log"
   rm -rf "${DIR}/functions/lib"