Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gradle): Dynamically resolve collectModulesScript path #3092

Merged
merged 5 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Fixes

- Dynamically resolve `collectModulesScript` path to support monorepos ([#3092])(https://github.com/getsentry/sentry-react-native/pull/3092)

### Dependencies

- Bump JavaScript SDK from v7.52.0 to v7.52.1 ([#3071](https://github.com/getsentry/sentry-react-native/pull/3071))
Expand Down
8 changes: 7 additions & 1 deletion sentry.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,15 @@ gradle.projectsEvaluated {

workingDir reactRoot

def resolvedSentryPath = null
try {
resolvedSentryPath = new File(["node", "--print", "require.resolve('@sentry/react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile();
} catch (Throwable ignored) {} // if the resolve fails we fallback to the default path
def sentryPackage = resolvedSentryPath != null && resolvedSentryPath.exists() ? resolvedSentryPath.getAbsolutePath() : "$reactRoot/node_modules/@sentry/react-native"

def collectModulesScript = config.collectModulesScript
? file(config.collectModulesScript).getAbsolutePath()
: "$reactRoot/node_modules/@sentry/react-native/dist/js/tools/collectModules.js"
: "$sentryPackage/dist/js/tools/collectModules.js"
def modulesPaths = config.modulesPaths
? config.modulesPaths.join(',')
: "$reactRoot/node_modules"
Expand Down