fix: init when there's a package.json in folder #1980
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
When
init
in a folder that contains any kind ofpackage.json
the failed with:This is due to
reactNativeVersion
introduced in #1870 accessing theinitialConfig.reactNativePath
getter, which throws in situations where there's nopackage.json
file available in the directory. Reading this infinalConfig
is fine, because when there's nopackage.json
, it skips the logic inside the.reduce
, which accessesinitialConfig.reactNativePath
variable.Tbh, this is rather convoluted logic and because of that during code review we failed identifying it as a potential problem. Let's treat this as a band-aid for now and as a followup think about refactoring this piece.
Test Plan:
I haven't really tested the versioned link generation, so please make sure to verify it