@@ -10,19 +10,32 @@ const fs = require('fs')
1010const resolve = require ( 'metro-resolver' ) . resolve
1111const here = fs . realpathSync . native ( __dirname )
1212const blacklist = require ( 'metro-config/src/defaults/blacklist' )
13+ const local_path = path . resolve ( '.' ) + '/node_modules/' ;
1314
1415// There is no good way to save the system `require()` before metro overwrites
1516// it. Plus metro does not handle cyclic dependencies well at all. We fix these by
1617// using our own implementation of metroRequire.
17- fs . writeFileSync ( path . resolve ( __dirname , '../node_modules/metro-config/src/defaults/defaults.js' ) ,
18- fs . readFileSync ( path . resolve ( __dirname , 'metro-polyfill/defaults.js' ) )
19- )
18+ try {
19+ fs . writeFileSync ( path . resolve ( __dirname , '../node_modules/metro-config/src/defaults/defaults.js' ) ,
20+ fs . readFileSync ( path . resolve ( __dirname , 'metro-polyfill/defaults.js' ) )
21+ )
22+ } catch ( e ) {
23+ fs . writeFileSync ( path . resolve ( local_path , 'metro-config/src/defaults/defaults.js' ) ,
24+ fs . readFileSync ( path . resolve ( __dirname , 'metro-polyfill/defaults.js' ) )
25+ )
26+ }
2027
2128// Patch for: https://github.com/facebook/metro/issues/330
2229// And disable throwOnModuleCollision -- this causes all kinds of problems and solves none.
23- fs . writeFileSync ( path . resolve ( __dirname , '../node_modules/metro/src/node-haste/DependencyGraph.js' ) ,
24- fs . readFileSync ( path . resolve ( __dirname , 'metro-polyfill/DependencyGraph.js' ) )
25- )
30+ try {
31+ fs . writeFileSync ( path . resolve ( __dirname , '../node_modules/metro/src/node-haste/DependencyGraph.js' ) ,
32+ fs . readFileSync ( path . resolve ( __dirname , 'metro-polyfill/DependencyGraph.js' ) )
33+ )
34+ } catch ( e ) {
35+ fs . writeFileSync ( path . resolve ( local_path , 'metro/src/node-haste/DependencyGraph.js' ) ,
36+ fs . readFileSync ( path . resolve ( __dirname , 'metro-polyfill/DependencyGraph.js' ) )
37+ )
38+ }
2639
2740const configure = ( config ) => {
2841 // Do not add all the react-native junk by default. This needs to be done
0 commit comments