findProject.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = findProject;
  6. function _glob() {
  7. const data = _interopRequireDefault(require("glob"));
  8. _glob = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. function _path() {
  14. const data = _interopRequireDefault(require("path"));
  15. _path = function () {
  16. return data;
  17. };
  18. return data;
  19. }
  20. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  21. /**
  22. * Copyright (c) Facebook, Inc. and its affiliates.
  23. *
  24. * This source code is licensed under the MIT license found in the
  25. * LICENSE file in the root directory of this source tree.
  26. *
  27. */
  28. /**
  29. * Glob pattern to look for xcodeproj
  30. */
  31. const GLOB_PATTERN = '**/*.xcodeproj';
  32. /**
  33. * Regexp matching all test projects
  34. */
  35. const TEST_PROJECTS = /test|example|sample/i;
  36. /**
  37. * Base iOS folder
  38. */
  39. const IOS_BASE = 'ios';
  40. /**
  41. * These folders will be excluded from search to speed it up
  42. */
  43. const GLOB_EXCLUDE_PATTERN = ['**/@(Pods|node_modules|Carthage)/**'];
  44. /**
  45. * Finds iOS project by looking for all .xcodeproj files
  46. * in given folder.
  47. *
  48. * Returns first match if files are found or null
  49. *
  50. * Note: `./ios/*.xcodeproj` are returned regardless of the name
  51. */
  52. function findProject(folder) {
  53. const projects = _glob().default.sync(GLOB_PATTERN, {
  54. cwd: folder,
  55. ignore: GLOB_EXCLUDE_PATTERN
  56. }).filter(project => _path().default.dirname(project) === IOS_BASE || !TEST_PROJECTS.test(project)).sort(project => _path().default.dirname(project) === IOS_BASE ? -1 : 1);
  57. if (projects.length === 0) {
  58. return null;
  59. }
  60. return projects[0];
  61. }
  62. //# sourceMappingURL=findProject.js.map