@@ -167,11 +167,7 @@ project.afterEvaluate {
167167 project. logger. info(" file not found '$propertiesFile ' for '$variant '" )
168168 }
169169
170- def resolvedCliPackage = null
171- try {
172- resolvedCliPackage = new File ([" node" , " --print" , " require.resolve('@sentry/cli/package.json')" ]. execute(null , rootDir). text. trim()). getParentFile();
173- } catch (Throwable ignored) {}
174- def cliPackage = resolvedCliPackage != null && resolvedCliPackage. exists() ? resolvedCliPackage. getAbsolutePath() : " $reactRoot /node_modules/@sentry/cli"
170+ def cliPackage = resolveSentryCliPackagePath(reactRoot)
175171 def cliExecutable = sentryProps. get(" cli.executable" , " $cliPackage /bin/sentry-cli" )
176172
177173 // fix path separator for Windows
@@ -306,6 +302,32 @@ def resolveSentryReactNativeSDKPath(reactRoot) {
306302 return sentryPackage
307303}
308304
305+ def resolveSentryCliPackagePath (reactRoot ) {
306+ def resolvedCliPath = null
307+ try {
308+ def file = new File ([" node" , " --print" , " require.resolve('@sentry/cli/package.json')" ]. execute(null , rootDir))
309+ resolvedCliPath = file. text. trim(). getParentFile();
310+ } catch (Throwable ignored) { // Check if it's located in .pnpm
311+ try {
312+ def pnpmRefPath = reactRoot. toString() + " /node_modules/@sentry/react-native/node_modules/.bin/sentry-cli"
313+ def sentryCliFile = new File (pnpmRefPath)
314+
315+ if (sentryCliFile. exists()) {
316+ def cliFileText = sentryCliFile. text
317+ def matcher = cliFileText =~ / NODE_PATH="([^"]*?)@sentry\/ cli\/ /
318+
319+ if (matcher. find()) {
320+ def match = matcher. group(1 )
321+ resolvedCliPath = new File (match + " @sentry/cli" )
322+ }
323+ }
324+ } catch (Throwable ignored2) {} // if the resolve fails we fallback to the default path
325+ }
326+
327+ def cliPackage = resolvedCliPath != null && resolvedCliPath. exists() ? resolvedCliPath. getAbsolutePath() : " $reactRoot /node_modules/@sentry/cli"
328+ return cliPackage
329+ }
330+
309331/* * Compose lookup map of build variants - to - outputs. */
310332def extractReleasesInfo () {
311333 def releases = [:]
0 commit comments