File tree Expand file tree Collapse file tree 3 files changed +866
-0
lines changed
Expand file tree Collapse file tree 3 files changed +866
-0
lines changed Original file line number Diff line number Diff line change 7373 "react-hot-loader" : " ^1.2.8" ,
7474 "react-router" : " ^1.0.0-rc1" ,
7575 "react-tap-event-plugin" : " ^0.2.0" ,
76+ "recursive-readdir-sync" : " ^1.0.6" ,
7677 "rimraf" : " ^2.4.3" ,
7778 "sinon" : " ^1.15.4" ,
7879 "sinon-chai" : " ^2.8.0" ,
Original file line number Diff line number Diff line change 1+ const fs = require ( 'fs' ) ;
2+ const rrs = require ( 'recursive-readdir-sync' ) ;
3+
4+ const outArray = [ ] ;
5+ outArray . push ( 'module.exports = {\n' ) ;
6+
7+ rrs ( './' ) . forEach ( function ( file ) {
8+ if ( file !== 'index-generator.js' && file !== 'index.js' )
9+ {
10+ var fileLines = fs . readFileSync ( file , 'utf8' ) . split ( '\n' ) ;
11+ var index = 0 , found = false ;
12+
13+ while ( found === false && index < fileLines . length )
14+ {
15+ if ( fileLines [ index ] . indexOf ( 'module.exports' ) > - 1 )
16+ {
17+ var moduleName = fileLines [ index ] . split ( '=' ) [ 1 ] . replace ( ';' , '' ) . trim ( ) ;
18+
19+ outArray . push ( '\t' ) ;
20+ outArray . push ( moduleName ) ;
21+ outArray . push ( ': require(\'./' ) ;
22+ outArray . push ( file . substring ( 0 , file . length - 4 ) ) ;
23+ outArray . push ( '\'),\n' ) ;
24+
25+ found = true ;
26+ }
27+
28+ else
29+ {
30+ index ++ ;
31+ }
32+ }
33+ }
34+ } ) ;
35+
36+ outArray . push ( '\n};\n' )
37+
38+ fs . writeFileSync ( 'index.js' , outArray . join ( '' ) ) ;
You can’t perform that action at this time.
0 commit comments