File tree 1 file changed +20
-1
lines changed
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
+
1
20
def safeExtGet (prop , fallback ) {
2
21
rootProject. ext. has(prop) ? rootProject. ext. get(prop) : fallback
3
22
}
@@ -53,7 +72,7 @@ repositories {
53
72
mavenLocal()
54
73
maven {
55
74
// 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"
57
76
}
58
77
google()
59
78
jcenter()
You can’t perform that action at this time.
0 commit comments