createGroup.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = createGroup;
  6. var _getGroup = _interopRequireDefault(require("./getGroup"));
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. /**
  9. * Copyright (c) Facebook, Inc. and its affiliates.
  10. *
  11. * This source code is licensed under the MIT license found in the
  12. * LICENSE file in the root directory of this source tree.
  13. *
  14. */
  15. const hasGroup = (pbxGroup, name) => pbxGroup.children.find(group => group.comment === name);
  16. /**
  17. * Given project and path of the group, it deeply creates a given group
  18. * making all outer groups if necessary
  19. *
  20. * Returns newly created group
  21. */
  22. function createGroup(project, path) {
  23. return path.split('/').reduce((group, name) => {
  24. if (!hasGroup(group, name)) {
  25. const uuid = project.pbxCreateGroup(name, '""');
  26. group.children.push({
  27. value: uuid,
  28. comment: name
  29. });
  30. }
  31. return project.pbxGroupByName(name);
  32. }, (0, _getGroup.default)(project));
  33. }
  34. //# sourceMappingURL=createGroup.js.map