mirror of
https://github.com/status-im/react-native.git
synced 2025-01-10 09:35:48 +00:00
0af640bfae
Summary: This commit removes `rnpm` folder that we left during initial merge to keep the diff cleaner. The `core`, `link` and `install` have now the same directory structure as any other command to make development more natural for all of us. From most notable differences: 1) the `src` folder is now gone. The new structure should make it easier for people to work with the stuff and also move us closer to 100% rnpm integration, 2) There's also no `package.json` present in any of the `rnpm` packages, since they are no longer standalone modules, 3) There's no `bugs.url` in link.js since main package.json of React doesn't specify it. Decided to hardcode it to facebook/react-native since it's really unlikely to change. If one would prefer to use pkg.bugs.url as before, a separate PR modifying package.json should be sent. Closes https://github.com/facebook/react-native/pull/9509 Differential Revision: D3751115 fbshipit-source-id: 74ae8330f7634df0887ad676808f47eee4b8de85
53 lines
1.8 KiB
JavaScript
53 lines
1.8 KiB
JavaScript
const path = require('path');
|
|
const union = require('lodash').union;
|
|
const last = require('lodash').last;
|
|
|
|
/**
|
|
* Given an array of directories, it returns the one that contains
|
|
* all the other directories in a given array inside it.
|
|
*
|
|
* Example:
|
|
* Given an array of directories: ['/Users/Kureev/a', '/Users/Kureev/b']
|
|
* the returned folder is `/Users/Kureev`
|
|
*
|
|
* Check `getHeaderSearchPath.spec.js` for more use-cases.
|
|
*/
|
|
const getOuterDirectory = (directories) =>
|
|
directories.reduce((topDir, currentDir) => {
|
|
const currentFolders = currentDir.split(path.sep);
|
|
const topMostFolders = topDir.split(path.sep);
|
|
|
|
if (currentFolders.length === topMostFolders.length
|
|
&& last(currentFolders) !== last(topMostFolders)) {
|
|
return currentFolders.slice(0, -1).join(path.sep);
|
|
}
|
|
|
|
return currentFolders.length < topMostFolders.length
|
|
? currentDir
|
|
: topDir;
|
|
});
|
|
|
|
/**
|
|
* Given an array of headers it returns search path so Xcode can resolve
|
|
* headers when referenced like below:
|
|
* ```
|
|
* #import "CodePush.h"
|
|
* ```
|
|
* If all files are located in one directory (directories.length === 1),
|
|
* we simply return a relative path to that location.
|
|
*
|
|
* Otherwise, we loop through them all to find the outer one that contains
|
|
* all the headers inside. That location is then returned with /** appended at
|
|
* the end so Xcode marks that location as `recursive` and will look inside
|
|
* every folder of it to locate correct headers.
|
|
*/
|
|
module.exports = function getHeaderSearchPath(sourceDir, headers) {
|
|
const directories = union(
|
|
headers.map(path.dirname)
|
|
);
|
|
|
|
return directories.length === 1
|
|
? `"$(SRCROOT)${path.sep}${path.relative(sourceDir, directories[0])}"`
|
|
: `"$(SRCROOT)${path.sep}${path.relative(sourceDir, getOuterDirectory(directories))}/**"`;
|
|
};
|