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-05-11 19:43:49 +00:00
|
|
|
*
|
|
|
|
* @format
|
2018-02-09 01:10:29 +00:00
|
|
|
*/
|
|
|
|
|
2016-05-20 11:52:08 +00:00
|
|
|
const getGroup = require('./getGroup');
|
|
|
|
|
2018-05-11 19:43:49 +00:00
|
|
|
const hasGroup = (pbxGroup, name) =>
|
|
|
|
pbxGroup.children.find(group => group.comment === name);
|
2016-05-20 11:52:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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) {
|
2018-05-11 19:43:49 +00:00
|
|
|
return path.split('/').reduce((group, name) => {
|
|
|
|
if (!hasGroup(group, name)) {
|
|
|
|
const uuid = project.pbxCreateGroup(name, '""');
|
2016-05-20 11:52:08 +00:00
|
|
|
|
2018-05-11 19:43:49 +00:00
|
|
|
group.children.push({
|
|
|
|
value: uuid,
|
|
|
|
comment: name,
|
|
|
|
});
|
|
|
|
}
|
2016-05-20 11:52:08 +00:00
|
|
|
|
2018-05-11 19:43:49 +00:00
|
|
|
return project.pbxGroupByName(name);
|
|
|
|
}, getGroup(project));
|
2016-05-20 11:52:08 +00:00
|
|
|
};
|