@@ -99,22 +99,33 @@ if (argv.init) {
9999 } else {
100100
101101 if ( cfg . es6 ) {
102- fs . readFile ( path . join ( __dirname , 'lib/files/component.jsx' ) , 'utf8' , ( e , contents ) => {
103- if ( e ) return cb ( err ) ;
102+ if ( argv . pure ) {
103+ fs . readFile ( path . join ( __dirname , 'lib/files/pure-component.jsx' ) , 'utf8' , ( e , contents ) => {
104+ if ( e ) return cb ( err ) ;
104105
105- contents = contents . replace ( / _ _ t p l _ n a m e _ _ / g, argv . _ [ 0 ] ) ;
106- contents = contents . replace ( / _ _ t p l _ c f g _ c s s _ _ / g, cfg . css ) ;
106+ contents = contents . replace ( / _ _ t p l _ n a m e _ _ / g, argv . _ [ 0 ] ) ;
107+ contents = contents . replace ( / _ _ t p l _ c f g _ c s s _ _ / g, cfg . css ) ;
107108
108- fs . appendFile ( path . join ( process . cwd ( ) , cfg . path , `${ argv . _ [ 0 ] } /${ argv . _ [ 0 ] } .${ cfg . extension } ` ) , contents , cb ) ;
109- } )
109+ fs . appendFile ( path . join ( process . cwd ( ) , cfg . path , `${ argv . _ [ 0 ] } /index.${ cfg . extension } ` ) , contents , cb ) ;
110+ } )
111+ } else {
112+ fs . readFile ( path . join ( __dirname , 'lib/files/component.jsx' ) , 'utf8' , ( e , contents ) => {
113+ if ( e ) return cb ( err ) ;
114+
115+ contents = contents . replace ( / _ _ t p l _ n a m e _ _ / g, argv . _ [ 0 ] ) ;
116+ contents = contents . replace ( / _ _ t p l _ c f g _ c s s _ _ / g, cfg . css ) ;
117+
118+ fs . appendFile ( path . join ( process . cwd ( ) , cfg . path , `${ argv . _ [ 0 ] } /index.${ cfg . extension } ` ) , contents , cb ) ;
119+ } )
120+ }
110121 } else {
111122 fs . readFile ( path . join ( __dirname , 'lib/files/functions-component.jsx' ) , 'utf8' , ( e , contents ) => {
112123 if ( e ) return cb ( err ) ;
113124
114125 contents = contents . replace ( / _ _ t p l _ n a m e _ _ / g, argv . _ [ 0 ] ) ;
115126 contents = contents . replace ( / _ _ t p l _ c f g _ c s s _ _ / g, cfg . css ) ;
116127
117- fs . appendFile ( path . join ( process . cwd ( ) , cfg . path , `${ argv . _ [ 0 ] } /${ argv . _ [ 0 ] } .${ cfg . extension } ` ) , contents , cb ) ;
128+ fs . appendFile ( path . join ( process . cwd ( ) , cfg . path , `${ argv . _ [ 0 ] } /index .${ cfg . extension } ` ) , contents , cb ) ;
118129 } )
119130 }
120131 }
0 commit comments