mirror of
https://github.com/status-im/react-navigation.git
synced 2025-02-24 17:18:09 +00:00
53 lines
1.5 KiB
JavaScript
53 lines
1.5 KiB
JavaScript
/**
|
|
* @noflow
|
|
*/
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const blacklist = require('metro/src/blacklist');
|
|
|
|
module.exports = {
|
|
getBlacklistRE() {
|
|
return blacklist([
|
|
/react\-navigation\/examples\/(?!ReduxExample).*/,
|
|
/react\-navigation\/node_modules\/react-native\/(.*)/,
|
|
/react\-navigation\/node_modules\/react\/(.*)/
|
|
]);
|
|
},
|
|
extraNodeModules: getNodeModulesForDirectory(path.resolve('.')),
|
|
};
|
|
|
|
function getNodeModulesForDirectory(rootPath) {
|
|
const nodeModulePath = path.join(rootPath, 'node_modules');
|
|
const folders = fs.readdirSync(nodeModulePath);
|
|
return folders.reduce((modules, folderName) => {
|
|
const folderPath = path.join(nodeModulePath, folderName);
|
|
if (folderName.startsWith('@')) {
|
|
const scopedModuleFolders = fs.readdirSync(folderPath);
|
|
const scopedModules = scopedModuleFolders.reduce(
|
|
(scopedModules, scopedFolderName) => {
|
|
scopedModules[
|
|
`${folderName}/${scopedFolderName}`
|
|
] = maybeResolveSymlink(path.join(folderPath, scopedFolderName));
|
|
return scopedModules;
|
|
},
|
|
{}
|
|
);
|
|
return Object.assign({}, modules, scopedModules);
|
|
}
|
|
modules[folderName] = maybeResolveSymlink(folderPath);
|
|
return modules;
|
|
}, {});
|
|
}
|
|
|
|
function maybeResolveSymlink(maybeSymlinkPath) {
|
|
if (fs.lstatSync(maybeSymlinkPath).isSymbolicLink()) {
|
|
const resolved = path.resolve(
|
|
path.dirname(maybeSymlinkPath),
|
|
fs.readlinkSync(maybeSymlinkPath)
|
|
);
|
|
return resolved;
|
|
}
|
|
return maybeSymlinkPath;
|
|
}
|