Skip to content

Commit

Permalink
fix(gradle): Dynamically resolve collectModulesScript path (#3092)
Browse files Browse the repository at this point in the history
Co-authored-by: Mateus Craveiro <[email protected]>
  • Loading branch information
krystofwoldrich and mccraveiro committed Jun 12, 2023
1 parent a3e554a commit 8236a9e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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.53.1 ([#3071](https://github.com/getsentry/sentry-react-native/pull/3071), [#3088](https://github.com/getsentry/sentry-react-native/pull/3088))
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

0 comments on commit 8236a9e

Please sign in to comment.