-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrn-cli.config.js
52 lines (48 loc) · 1.53 KB
/
rn-cli.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* @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;
}