addPodEntry.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = addPodEntry;
  6. function _cliTools() {
  7. const data = require("@react-native-community/cli-tools");
  8. _cliTools = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. var _getPodspecName = _interopRequireDefault(require("../config/getPodspecName"));
  14. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  15. /**
  16. * Copyright (c) Facebook, Inc. and its affiliates.
  17. *
  18. * This source code is licensed under the MIT license found in the
  19. * LICENSE file in the root directory of this source tree.
  20. *
  21. */
  22. function addPodEntry(podLines, linesToAddEntry, podspecPath, nodeModulePath) {
  23. const podName = (0, _getPodspecName.default)(podspecPath);
  24. const newEntry = `pod '${podName}', :path => '../node_modules/${nodeModulePath}'\n`;
  25. if (!linesToAddEntry) {
  26. return;
  27. }
  28. if (Array.isArray(linesToAddEntry)) {
  29. linesToAddEntry.map(({
  30. line,
  31. indentation
  32. }, idx) => {
  33. _cliTools().logger.debug(`Adding ${podName} to Pod file"`);
  34. podLines.splice(line + idx, 0, getLineToAdd(newEntry, indentation));
  35. });
  36. } else {
  37. const {
  38. line,
  39. indentation
  40. } = linesToAddEntry;
  41. _cliTools().logger.debug(`Adding ${podName} to Pod file"`);
  42. podLines.splice(line, 0, getLineToAdd(newEntry, indentation));
  43. }
  44. }
  45. function getLineToAdd(newEntry, indentation) {
  46. const spaces = Array(indentation + 1).join(' ');
  47. return spaces + newEntry;
  48. }
  49. //# sourceMappingURL=addPodEntry.js.map