Skip to content

Commit 504405d

Browse files
tido64thymikee
andauthored
fix: allow dependency.platforms.[platform] to be null again (#1613)
* fix: allow `dependency.platforms.[platform]` to be `null` again * chore: add test Co-authored-by: Michał Pierzchała <[email protected]>
1 parent e9e89eb commit 504405d

File tree

5 files changed

+52
-4
lines changed

5 files changed

+52
-4
lines changed

packages/cli-config/src/__tests__/__snapshots__/index-test.ts.snap

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,14 @@ Object {
145145
"root": "<<REPLACED>>/node_modules/react-native-test",
146146
}
147147
`;
148+
149+
exports[`supports disabling dependency for ios platform 1`] = `
150+
Object {
151+
"name": "react-native-test",
152+
"platforms": Object {
153+
"android": null,
154+
"ios": null,
155+
},
156+
"root": "<<REPLACED>>/node_modules/react-native-test",
157+
}
158+
`;

packages/cli-config/src/__tests__/index-test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,3 +339,32 @@ test('supports dependencies from user configuration with custom build type', ()
339339
removeString(dependencies['react-native-test'], DIR),
340340
).toMatchSnapshot();
341341
});
342+
343+
test('supports disabling dependency for ios platform', () => {
344+
DIR = getTempDirectory('config_test_disable_dependency_platform');
345+
writeFiles(DIR, {
346+
...REACT_NATIVE_MOCK,
347+
'node_modules/react-native-test/package.json': '{}',
348+
'node_modules/react-native-test/ReactNativeTest.podspec': '',
349+
'node_modules/react-native-test/react-native.config.js': `
350+
module.exports = {
351+
dependency: {
352+
platforms: {
353+
ios: null
354+
}
355+
}
356+
}
357+
`,
358+
'package.json': `{
359+
"dependencies": {
360+
"react-native": "0.0.1",
361+
"react-native-test": "0.0.1"
362+
}
363+
}`,
364+
});
365+
366+
const {dependencies} = loadConfig(DIR);
367+
expect(
368+
removeString(dependencies['react-native-test'], DIR),
369+
).toMatchSnapshot();
370+
});

packages/cli-config/src/schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export const dependencyConfig = t
7272
scriptPhases: t.array().items(t.object()),
7373
configurations: t.array().items(t.string()).default([]),
7474
})
75-
.default({}),
75+
.allow(null),
7676
android: t
7777
// AndroidDependencyParams
7878
.object({
@@ -87,7 +87,7 @@ export const dependencyConfig = t
8787
componentDescriptors: t.array().items(t.string()).allow(null),
8888
androidMkPath: t.string().allow(null),
8989
})
90-
.default({}),
90+
.allow(null),
9191
})
9292
.default(),
9393
})

packages/platform-android/src/config/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,12 @@ function getAppName(sourceDir: string, userConfigAppName: string | undefined) {
8080
*/
8181
export function dependencyConfig(
8282
root: string,
83-
userConfig: AndroidDependencyParams = {},
83+
userConfig: AndroidDependencyParams | null = {},
8484
): AndroidDependencyConfig | null {
85+
if (userConfig === null) {
86+
return null;
87+
}
88+
8589
const src = userConfig.sourceDir || findAndroidDir(root);
8690

8791
if (!src) {

packages/platform-ios/src/config/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,12 @@ export function projectConfig(
5252

5353
export function dependencyConfig(
5454
folder: string,
55-
userConfig: IOSDependencyParams,
55+
userConfig: IOSDependencyParams | null = {},
5656
): IOSDependencyConfig | null {
57+
if (userConfig === null) {
58+
return null;
59+
}
60+
5761
const podspecPath = findPodspec(folder);
5862

5963
if (!podspecPath) {

0 commit comments

Comments
 (0)