diff --git a/CHANGELOG.md b/CHANGELOG.md index c38172ad7..629e88fd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ ``` - Only upload Expo artifact if source map exists ([#3568](https://github.com/getsentry/sentry-react-native/pull/3568)) +- Read `.env` file in `sentry-expo-upload-sourcemaps` ([#3571](https://github.com/getsentry/sentry-react-native/pull/3571)) ### Fixes diff --git a/scripts/expo-upload-sourcemaps.js b/scripts/expo-upload-sourcemaps.js index 911f685bf..11600a446 100755 --- a/scripts/expo-upload-sourcemaps.js +++ b/scripts/expo-upload-sourcemaps.js @@ -101,6 +101,15 @@ function groupAssets(assetPaths) { return groups; } +process.env.NODE_ENV = process.env.NODE_ENV || 'development'; // Ensures precedence .env.development > .env (the same as @expo/cli) +const projectRoot = '.'; // Assume script is run from the project root +try { + require('@expo/env').load(projectRoot); +} catch (error) { + console.warn('⚠️ Failed to load environment variables using @expo/env.'); + console.warn(error); +} + let sentryOrg = getEnvVar(SENTRY_ORG); let sentryProject = getEnvVar(SENTRY_PROJECT); let authToken = getEnvVar(SENTRY_AUTH_TOKEN);