UNPKG

1.97 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = findPodfilePath;
7
8function _cliTools() {
9 const data = require("@react-native-community/cli-tools");
10
11 _cliTools = function () {
12 return data;
13 };
14
15 return data;
16}
17
18function _path() {
19 const data = _interopRequireDefault(require("path"));
20
21 _path = function () {
22 return data;
23 };
24
25 return data;
26}
27
28var _findAllPodfilePaths = _interopRequireDefault(require("./findAllPodfilePaths"));
29
30function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
32/**
33 * Copyright (c) Facebook, Inc. and its affiliates.
34 *
35 * This source code is licensed under the MIT license found in the
36 * LICENSE file in the root directory of this source tree.
37 *
38 */
39// Regexp matching all test projects
40const TEST_PROJECTS = /test|example|sample/i; // Base iOS folder
41
42const IOS_BASE = 'ios';
43
44function findPodfilePath(cwd) {
45 const podfiles = (0, _findAllPodfilePaths.default)(cwd)
46 /**
47 * Then, we will run a simple test to rule out most example projects,
48 * unless they are located in a `ios` folder
49 */
50 .filter(project => _path().default.dirname(project) === IOS_BASE || !TEST_PROJECTS.test(project))
51 /**
52 * Podfile from `ios` folder will be picked up as a first one.
53 */
54 .sort(project => _path().default.dirname(project) === IOS_BASE ? -1 : 1);
55
56 if (podfiles.length > 0) {
57 if (podfiles.length > 1) {
58 _cliTools().logger.warn((0, _cliTools().inlineString)(`
59 Multiple Podfiles were found: ${podfiles}. Choosing ${podfiles[0]} automatically.
60 If you would like to select a different one, you can configure it via "project.ios.sourceDir".
61 You can learn more about it here: https://github.com/react-native-community/cli/blob/master/docs/configuration.md
62 `));
63 }
64
65 return _path().default.join(cwd, podfiles[0]);
66 }
67
68 return null;
69}
70
71//# sourceMappingURL=findPodfilePath.js.map
\No newline at end of file