Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ Object {
}
`;

exports[`should not add default React Native config when one present 1`] = `
Array [
Object {
"func": [Function],
"name": "test",
},
]
`;

exports[`should read \`rnpm\` config from a dependency and transform it to a new format 1`] = `
Object {
"assets": Array [],
Expand Down
19 changes: 19 additions & 0 deletions packages/cli/src/tools/config/__tests__/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,22 @@ test('should automatically put "react-native" into haste config', () => {
const {haste} = loadConfig(DIR);
expect(haste).toMatchSnapshot();
});

test('should not add default React Native config when one present', () => {
writeFiles(DIR, {
'node_modules/react-native/package.json': '{}',
'node_modules/react-native/react-native.config.js': `module.exports = {
commands: [{
name: 'test',
func: () => {},
}]
}`,
'package.json': `{
"dependencies": {
"react-native": "0.0.1"
}
}`,
});
const {commands} = loadConfig(DIR);
expect(commands).toMatchSnapshot();
});
14 changes: 11 additions & 3 deletions packages/cli/src/tools/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,18 @@ function loadConfig(projectRoot: string = process.cwd()): ConfigT {
readLegacyDependencyConfigFromDisk(root) ||
readDependencyConfigFromDisk(root);

// @todo: Move this to React Native in the future
/**
* This workaround is neccessary for development only before
* first 0.60.0-rc.0 gets released and we can switch to it
* while testing.
*/
if (dependencyName === 'react-native') {
config.platforms = {ios, android};
config.commands = [...ios.commands, ...android.commands];
if (Object.keys(config.platforms).length === 0) {
config.platforms = {ios, android};
}
if (config.commands.length === 0) {
config.commands = [...ios.commands, ...android.commands];
}
}

const isPlatform = Object.keys(config.platforms).length > 0;
Expand Down