Skip to content

Commit

Permalink
Add manifestPath userConfig.
Browse files Browse the repository at this point in the history
`react-native link` often fails due to the wrong manifest being used when you use a debug manifest.
  • Loading branch information
dantman committed Apr 22, 2017
1 parent 03ea65e commit 5ccb882
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
19 changes: 19 additions & 0 deletions local-cli/core/__fixtures__/android.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,25 @@ exports.valid = {
},
};

exports.userConfigManifest = {
src: {
main: {
'AndroidManifest.xml': manifest,
com: {
some: {
example: {
'Main.java': mainJavaClass,
'ReactPackage.java': fs.readFileSync(path.join(__dirname, './files/ReactPackage.java')),
},
},
},
},
debug: {
'AndroidManifest.xml': fs.readFileSync(path.join(__dirname, './files/AndroidManifest-debug.xml')),
},
},
};

exports.corrupted = {
src: {
'AndroidManifest.xml': manifest,
Expand Down
3 changes: 3 additions & 0 deletions local-cli/core/__fixtures__/files/AndroidManifest-debug.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
13 changes: 13 additions & 0 deletions local-cli/core/__tests__/android/getProjectConfig.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ describe('android::getProjectConfig', () => {
flat: {
android: mocks.valid,
},
multiple: {
android: mocks.userConfigManifest,
},
noManifest: {
android: {},
},
Expand Down Expand Up @@ -43,6 +46,16 @@ describe('android::getProjectConfig', () => {
expect(getProjectConfig(folder, userConfig)).not.toBe(null);
expect(typeof getProjectConfig(folder, userConfig)).toBe('object');
});

it('multiple', () => {
const userConfig = {
manifestPath: 'src/main/AndroidManifest.xml'
};
const folder = 'multiple';

expect(getProjectConfig(folder, userConfig)).not.toBe(null);
expect(typeof getProjectConfig(folder, userConfig)).toBe('object');
});
});

it('should return `null` if android project was not found', () => {
Expand Down
8 changes: 6 additions & 2 deletions local-cli/core/android/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ exports.projectConfig = function projectConfigAndroid(folder, userConfig) {

const sourceDir = path.join(folder, src);
const isFlat = sourceDir.indexOf('app') === -1;
const manifestPath = findManifest(sourceDir);
const manifestPath = userConfig.manifestPath
? path.join(sourceDir, userConfig.manifestPath)
: findManifest(sourceDir);

if (!manifestPath) {
return null;
Expand Down Expand Up @@ -97,7 +99,9 @@ exports.dependencyConfig = function dependencyConfigAndroid(folder, userConfig)
}

const sourceDir = path.join(folder, src);
const manifestPath = findManifest(sourceDir);
const manifestPath = userConfig.manifestPath
? path.join(sourceDir, userConfig.manifestPath)
: findManifest(sourceDir);

if (!manifestPath) {
return null;
Expand Down

0 comments on commit 5ccb882

Please sign in to comment.