isInstalled.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = isInstalled;
  6. var _readPodfile = _interopRequireDefault(require("./readPodfile"));
  7. var _getPodspecName = _interopRequireDefault(require("../config/getPodspecName"));
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. /**
  10. * Copyright (c) Facebook, Inc. and its affiliates.
  11. *
  12. * This source code is licensed under the MIT license found in the
  13. * LICENSE file in the root directory of this source tree.
  14. *
  15. */
  16. function isInstalled(iOSProject, dependencyConfig) {
  17. if (!iOSProject.podfile || !dependencyConfig.podspecPath) {
  18. return false;
  19. } // match line with pod declaration: pod 'dependencyPodName' (other possible parameters of pod are ignored)
  20. const dependencyRegExp = new RegExp(`pod\\s+('|")${(0, _getPodspecName.default)(dependencyConfig.podspecPath)}('|")`, 'g');
  21. const podLines = (0, _readPodfile.default)(iOSProject.podfile);
  22. for (let i = 0, len = podLines.length; i < len; i++) {
  23. const match = podLines[i].match(dependencyRegExp);
  24. if (match) {
  25. return true;
  26. }
  27. }
  28. return false;
  29. }
  30. //# sourceMappingURL=isInstalled.js.map