mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-01 14:15:03 +00:00
refactor: use node resolver to locate React Native package (#2461)
# Summary Twin pull request to https://github.com/software-mansion/react-native-reanimated/pull/6482
This commit is contained in:
+4
-10
@@ -43,16 +43,10 @@ def resolveReactNativeDirectory() {
|
||||
return file(reactNativeLocation)
|
||||
}
|
||||
|
||||
// monorepo workaround
|
||||
// react-native can be hoisted or in project's own node_modules
|
||||
def reactNativeFromProjectNodeModules = file("${rootProject.projectDir}/../node_modules/react-native")
|
||||
if (reactNativeFromProjectNodeModules.exists()) {
|
||||
return reactNativeFromProjectNodeModules
|
||||
}
|
||||
|
||||
def reactNativeFromNodeModulesWithSVG = file("${projectDir}/../../react-native")
|
||||
if (reactNativeFromNodeModulesWithSVG.exists()) {
|
||||
return reactNativeFromNodeModulesWithSVG
|
||||
// Fallback to node resolver for custom directory structures like monorepos.
|
||||
def reactNativePackage = file(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim())
|
||||
if (reactNativePackage.exists()) {
|
||||
return reactNativePackage.parentFile
|
||||
}
|
||||
|
||||
throw new GradleException("[react-native-svg] Unable to resolve react-native location in node_modules. Your app should define `REACT_NATIVE_NODE_MODULES_DIR` extension property in `app/build.gradle` with a path to react-native in node_modules.")
|
||||
|
||||
Reference in New Issue
Block a user