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
11 changes: 11 additions & 0 deletions packages/cli-config/src/__tests__/__snapshots__/index-test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,14 @@ Object {
"root": "<<REPLACED>>/node_modules/react-native-test",
}
`;

exports[`supports disabling dependency for ios platform 1`] = `
Object {
"name": "react-native-test",
"platforms": Object {
"android": null,
"ios": null,
},
"root": "<<REPLACED>>/node_modules/react-native-test",
}
`;
29 changes: 29 additions & 0 deletions packages/cli-config/src/__tests__/index-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,32 @@ test('supports dependencies from user configuration with custom build type', ()
removeString(dependencies['react-native-test'], DIR),
).toMatchSnapshot();
});

test('supports disabling dependency for ios platform', () => {
DIR = getTempDirectory('config_test_disable_dependency_platform');
writeFiles(DIR, {
...REACT_NATIVE_MOCK,
'node_modules/react-native-test/package.json': '{}',
'node_modules/react-native-test/ReactNativeTest.podspec': '',
'node_modules/react-native-test/react-native.config.js': `
module.exports = {
dependency: {
platforms: {
ios: null
}
}
}
`,
'package.json': `{
"dependencies": {
"react-native": "0.0.1",
"react-native-test": "0.0.1"
}
}`,
});

const {dependencies} = loadConfig(DIR);
expect(
removeString(dependencies['react-native-test'], DIR),
).toMatchSnapshot();
});
4 changes: 2 additions & 2 deletions packages/cli-config/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const dependencyConfig = t
scriptPhases: t.array().items(t.object()),
configurations: t.array().items(t.string()).default([]),
})
.default({}),
.allow(null),
android: t
// AndroidDependencyParams
.object({
Expand All @@ -87,7 +87,7 @@ export const dependencyConfig = t
componentDescriptors: t.array().items(t.string()).allow(null),
androidMkPath: t.string().allow(null),
})
.default({}),
.allow(null),
})
.default(),
})
Expand Down
6 changes: 5 additions & 1 deletion packages/platform-android/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,12 @@ function getAppName(sourceDir: string, userConfigAppName: string | undefined) {
*/
export function dependencyConfig(
root: string,
userConfig: AndroidDependencyParams = {},
userConfig: AndroidDependencyParams | null = {},
): AndroidDependencyConfig | null {
if (userConfig === null) {
return null;
}

const src = userConfig.sourceDir || findAndroidDir(root);

if (!src) {
Expand Down
6 changes: 5 additions & 1 deletion packages/platform-ios/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ export function projectConfig(

export function dependencyConfig(
folder: string,
userConfig: IOSDependencyParams,
userConfig: IOSDependencyParams | null = {},
): IOSDependencyConfig | null {
if (userConfig === null) {
return null;
}

const podspecPath = findPodspec(folder);

if (!podspecPath) {
Expand Down