Browse Source

dev_env(fix): Delete log file generated by direnv (#24403)

We were not deleting it in case of success.

Co-authored-by: Billy Vong <billyvg@users.noreply.github.com>
Armen Zambrano G 4 years ago
parent
commit
08d524a65c
1 changed files with 8 additions and 3 deletions
  1. 8 3
      .envrc

+ 8 - 3
.envrc

@@ -6,7 +6,9 @@
 
 set -e
 
-_SENTRY_LOG_FILE=$(mktemp -t sentry-direnv-envrc.out)
+# Since direnv traps the EXIT signal we place the temp file under /tmp for the odd time
+# the script will use the EXIT path
+_SENTRY_LOG_FILE=$(mktemp /tmp/sentry.envrc.$$.out)
 exec > >(tee "$_SENTRY_LOG_FILE")
 exec 2>&1
 
@@ -34,7 +36,7 @@ Follow them, and then you'll need to redo direnv by running "direnv allow".${res
 
 If you're stuck or have questions, ask in #discuss-dev-tooling.
 EOF
-    report_to_sentry
+    [ -z "${SENTRY_DEVENV_NO_REPORT+x}" ] && report_to_sentry
 }
 
 report_to_sentry() {
@@ -124,7 +126,7 @@ export NODE_OPTIONS=--max-old-space-size=4096
 export SENTRY_UI_HOT_RELOAD=1
 
 ## Notify of reporting to Sentry
-if [ "$SENTRY_DEVENV_NO_REPORT" ]; then
+if [ -n "${SENTRY_DEVENV_NO_REPORT+x}" ]; then
     info "No development environment errors will be reported (since you've defined SENTRY_DEVENV_NO_REPORT)."
 else
     info "Development errors will be reported to Sentry.io."$'\n'"        If you wish to opt-out, set SENTRY_DEVENV_NO_REPORT as an env variable."
@@ -231,3 +233,6 @@ If you're stuck or have questions, ask in #discuss-dev-tooling.
 
 EOF
 fi
+
+# Since we can't use an EXIT routine we need to guarantee we delete the file here
+rm "$_SENTRY_LOG_FILE"