mirror of
https://github.com/status-im/react-native.git
synced 2025-02-24 07:08:27 +00:00
Summary: Fixes `no-shadow` warning for `local-cli/link/ios/getGroup.js` and remove `var` declaration keyword. ``` react-native/local-cli/link/ios/getGroup.js 13:23 warning 'group' is already declared in the upper scope no-shadow ``` - [x] Check `npm run flow` - [x] Check `npm run flow-check-ios` - [x] Check `npm run flow-check-android` - [x] Check `npm run lint` N/A Pull Request resolved: https://github.com/facebook/react-native/pull/22124 Differential Revision: D12929717 Pulled By: TheSavior fbshipit-source-id: 10f8269ae7a0e61f4d0ec6fe710889c3a7c90b3b
45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
const getFirstProject = project => project.getFirstProject().firstProject;
|
|
|
|
const findGroup = (groups, name) =>
|
|
groups.children.find(group => group.comment === name);
|
|
|
|
/**
|
|
* Returns group from .xcodeproj if one exists, null otherwise
|
|
*
|
|
* Unlike node-xcode `pbxGroupByName` - it does not return `first-matching`
|
|
* group if multiple groups with the same name exist
|
|
*
|
|
* If path is not provided, it returns top-level group
|
|
*/
|
|
module.exports = function getGroup(project, path) {
|
|
const firstProject = getFirstProject(project);
|
|
|
|
let groups = project.getPBXGroupByKey(firstProject.mainGroup);
|
|
|
|
if (!path) {
|
|
return groups;
|
|
}
|
|
|
|
for (var name of path.split('/')) {
|
|
var foundGroup = findGroup(groups, name);
|
|
|
|
if (foundGroup) {
|
|
groups = project.getPBXGroupByKey(foundGroup.value);
|
|
} else {
|
|
groups = null;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return groups;
|
|
};
|