File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 1+ import java.nio.file.Paths
2+
3+ def resolveModulePath (packageName ) {
4+ def basePath = rootDir. toPath(). normalize()
5+
6+ // Node's module resolution algorithm searches up to the root directory,
7+ // after which the base path will be null
8+ while (basePath) {
9+ def candidatePath = Paths . get(basePath. toString(), ' node_modules' , packageName)
10+ if (candidatePath. toFile(). exists()) {
11+ return candidatePath. toString()
12+ }
13+
14+ basePath = basePath. getParent()
15+ }
16+
17+ return null
18+ }
19+
120def safeExtGet (prop , fallback ) {
221 rootProject. ext. has(prop) ? rootProject. ext. get(prop) : fallback
322}
@@ -53,7 +72,7 @@ repositories {
5372 mavenLocal()
5473 maven {
5574 // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
56- url " $r ootDir /../node_modules/ react-native/android"
75+ url " ${ resolveModulePath(" react-native") } /android"
5776 }
5877 google()
5978 jcenter()
You can’t perform that action at this time.
0 commit comments