2018-02-09 01:10:29 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2018-02-09 01:10:29 +00:00
|
|
|
*/
|
|
|
|
|
2016-05-20 11:52:08 +00:00
|
|
|
const getGroup = require('./getGroup');
|
|
|
|
|
|
|
|
const hasGroup = (pbxGroup, name) => pbxGroup.children.find(group => group.comment === name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Given project and path of the group, it deeply creates a given group
|
2018-01-13 06:03:51 +00:00
|
|
|
* making all outer groups if necessary
|
2016-05-20 11:52:08 +00:00
|
|
|
*
|
|
|
|
* Returns newly created group
|
|
|
|
*/
|
|
|
|
module.exports = function createGroup(project, path) {
|
|
|
|
return path.split('/').reduce(
|
|
|
|
(group, name) => {
|
|
|
|
if (!hasGroup(group, name)) {
|
|
|
|
const uuid = project.pbxCreateGroup(name, '""');
|
|
|
|
|
|
|
|
group.children.push({
|
|
|
|
value: uuid,
|
|
|
|
comment: name,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return project.pbxGroupByName(name);
|
|
|
|
},
|
|
|
|
getGroup(project)
|
|
|
|
);
|
|
|
|
};
|