Allow for undefined userConfig (#18660)

Summary:
Fixes #18249

This PR fixes an error that occurs when running `react-native link` in projects laid out as described on the React Native website section on integrating with existing apps (https://facebook.github.io/react-native/docs/integration-with-existing-apps.html) where an `ios/` subdirectory exists but an `android/` subdirectory does not exist

<img width="1050" alt="screenshot 2018-04-02 14 57 27" src="https://user-images.githubusercontent.com/2475286/38210733-3f4bd9ea-3686-11e8-9bd3-d299812a015c.png">

None

[CLI] [BUGFIX] [local-cli/core/android/index.js] - Allow for undefined userConfig
Pull Request resolved: https://github.com/facebook/react-native/pull/18660

Differential Revision: D9235171

Pulled By: hramos

fbshipit-source-id: 230dd54f8911046f7e01633f99c4f02070fa0172
This commit is contained in:
Justin Chapman 2018-08-08 21:01:23 -07:00 committed by Facebook Github Bot
parent 370e0db970
commit d154e9ec9d
2 changed files with 9 additions and 2 deletions

View File

@ -37,6 +37,13 @@ describe('android::getProjectConfig', () => {
});
});
it("returns `null` if manifest file hasn't been found and userConfig is not defined", () => {
const userConfig = undefined;
const folder = '/noManifest';
expect(getProjectConfig(folder, userConfig)).toBeNull();
});
it("returns `null` if manifest file hasn't been found", () => {
const userConfig = {};
const folder = '/noManifest';

View File

@ -21,7 +21,7 @@ const getPackageName = manifest => manifest.attr.package;
* Gets android project config by analyzing given folder and taking some
* defaults specified by user into consideration
*/
exports.projectConfig = function projectConfigAndroid(folder, userConfig) {
exports.projectConfig = function projectConfigAndroid(folder, userConfig = {}) {
const src = userConfig.sourceDir || findAndroidAppFolder(folder);
if (!src) {
@ -95,7 +95,7 @@ exports.projectConfig = function projectConfigAndroid(folder, userConfig) {
*/
exports.dependencyConfig = function dependencyConfigAndroid(
folder,
userConfig,
userConfig = {},
) {
const src = userConfig.sourceDir || findAndroidAppFolder(folder);