From 9b2cc5076cfa4d821ff2a0b6b9cb8e59f9520882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eloy=20Dur=C3=A1n?= Date: Wed, 20 Mar 2019 19:17:07 +0000 Subject: [PATCH] =?UTF-8?q?[config]=20Don=E2=80=99t=20include=20iOS=20conf?= =?UTF-8?q?ig=20when=20pkg=20has=20no=20podspec.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__tests__/ios/findPodspecName-test.js | 6 ++-- .../__tests__/ios/getDependencyConfig-test.js | 28 +++++++++++++++++++ packages/cli/src/tools/ios/findPodspecName.js | 2 +- packages/cli/src/tools/ios/index.js | 5 ++-- 4 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 packages/cli/src/tools/__tests__/ios/getDependencyConfig-test.js diff --git a/packages/cli/src/tools/__tests__/ios/findPodspecName-test.js b/packages/cli/src/tools/__tests__/ios/findPodspecName-test.js index a6a5d157eb..5e0393a124 100644 --- a/packages/cli/src/tools/__tests__/ios/findPodspecName-test.js +++ b/packages/cli/src/tools/__tests__/ios/findPodspecName-test.js @@ -25,7 +25,7 @@ describe('ios::findPodspecName', () => { it('returns podspec name if only one exists', () => { fs.__setMockFilesystem(ios.pod); - expect(findPodspecName('/')).toBe('TestPod'); + expect(findPodspecName('/')).toBe('TestPod.podspec'); }); it('returns podspec name that match packet directory', () => { @@ -37,7 +37,7 @@ describe('ios::findPodspecName', () => { }, }, }); - expect(findPodspecName('/user/PacketName')).toBe('PacketName'); + expect(findPodspecName('/user/PacketName')).toBe('PacketName.podspec'); }); it('returns first podspec name if not match in directory', () => { @@ -49,6 +49,6 @@ describe('ios::findPodspecName', () => { }, }, }); - expect(findPodspecName('/user/packet')).toBe('Another'); + expect(findPodspecName('/user/packet')).toBe('Another.podspec'); }); }); diff --git a/packages/cli/src/tools/__tests__/ios/getDependencyConfig-test.js b/packages/cli/src/tools/__tests__/ios/getDependencyConfig-test.js new file mode 100644 index 0000000000..b64ed3d5e5 --- /dev/null +++ b/packages/cli/src/tools/__tests__/ios/getDependencyConfig-test.js @@ -0,0 +1,28 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @emails oncall+javascript_foundation + */ + +import {getDependencyConfig} from '../../ios'; +import findPodspecName from '../../ios/findPodspecName'; + +jest.mock('../../ios/findPodspecName'); + +describe('ios::getDependencyConfig', () => { + it('returns null if there is no podspec file', () => { + findPodspecName.mockImplementation(() => null); + expect(getDependencyConfig('some/dir/without/podspec')).toBeNull(); + }); + + it('returns an object with the podspec name if one exists', () => { + findPodspecName.mockImplementation(() => 'TestPod.podspec'); + expect(getDependencyConfig('some/dir/with/podspec')).toEqual({ + podspec: 'TestPod.podspec', + }); + }); +}); diff --git a/packages/cli/src/tools/ios/findPodspecName.js b/packages/cli/src/tools/ios/findPodspecName.js index 08b8ec83c1..35840ecf81 100644 --- a/packages/cli/src/tools/ios/findPodspecName.js +++ b/packages/cli/src/tools/ios/findPodspecName.js @@ -29,5 +29,5 @@ export default function findPodspecName(folder) { } } - return podspecFile.replace('.podspec', ''); + return podspecFile; } diff --git a/packages/cli/src/tools/ios/index.js b/packages/cli/src/tools/ios/index.js index 255e559d66..8698732822 100644 --- a/packages/cli/src/tools/ios/index.js +++ b/packages/cli/src/tools/ios/index.js @@ -63,7 +63,6 @@ export const dependencyConfig = projectConfig; * New version of `ios` configuration */ export function getDependencyConfig(folder) { - return { - podspec: findPodspecName(folder), - }; + const podspec = findPodspecName(folder); + return podspec && {podspec}; }