Skip to content

Commit

Permalink
feat(expo): read .env file in upload script (#3571)
Browse files Browse the repository at this point in the history
  • Loading branch information
quinlanj authored Jan 31, 2024
1 parent 6c91dce commit a588df8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions scripts/expo-upload-sourcemaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a588df8

Please sign in to comment.