-
Notifications
You must be signed in to change notification settings - Fork 24.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support additional dependency declaration format
Previously, `isInstalled` was somewhat naively checking for the presence of a string in the `build.gradle` file to determine whether or not that dependency was already linked. I.e.: ` compile project(':${name}')\n` …where `name` is replaced with the name of the dependency being checked. This was inflexible as it only supported that particular format of `compile` definition. Another, valid `compile` definition follows: ` compile(project(':example') { … }` However, this failed the check because it didn't exactly match the format for which the check was searching the `build.gradle` contents. As a result, running `react-native link` would incorrectly duplicate the dependency definition and thus cause a crash upon launching the app. This change adds an `installPattern` to the object returned from `makeBuildPatch`, which includes the particular dependency name and is valid for both `compile` definition formats.
- Loading branch information
1 parent
40b5486
commit dda1374
Showing
5 changed files
with
21 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
module.exports = function makeBuildPatch(name) { | ||
const installPattern = new RegExp( | ||
`\\s{4}(compile)(\\(|\\s)(project)\\(\\\':${name}\\\'\\)(\\)|\\s)` | ||
) | ||
|
||
return { | ||
installPattern, | ||
pattern: /[^ \t]dependencies {\n/, | ||
patch: ` compile project(':${name}')\n`, | ||
patch: ` compile project(':${name}')\n` | ||
}; | ||
}; |