@@ -60,43 +60,64 @@ function Generator() {
6060 }
6161
6262 this . sourceRoot ( path . join ( __dirname , sourceRoot ) ) ;
63+
64+ this . moduleName = this . _ . camelize ( this . appname ) + 'App' ;
65+
66+ this . namespace = [ ] ;
67+ if ( this . name . indexOf ( '/' ) !== - 1 ) {
68+ this . namespace = this . name . split ( '/' ) ;
69+ this . name = this . namespace . pop ( ) ;
70+
71+ this . moduleName += '.' + this . namespace . join ( '.' ) ; // add to parent ?
72+ }
73+
6374}
6475
6576util . inherits ( Generator , yeoman . generators . NamedBase ) ;
6677
67- Generator . prototype . appTemplate = function ( src , dest ) {
78+ Generator . prototype . _dest = function ( src ) {
79+ if ( src . indexOf ( 'spec/' ) === 0 ) {
80+ src = src . substr ( 5 ) ;
81+ } else if ( src . indexOf ( 'service/' ) === 0 ) {
82+ src = src . substr ( 8 ) ;
83+ }
84+ return path . join ( ( this . namespace . join ( '/' ) || src ) , this . name ) ;
85+ } ;
86+
87+ Generator . prototype . appTemplate = function ( src ) {
6888 yeoman . generators . Base . prototype . template . apply ( this , [
6989 src + this . scriptSuffix ,
70- path . join ( this . env . options . appPath , dest ) + this . scriptSuffix
90+ path . join ( this . env . options . appPath , this . _dest ( src ) ) + this . scriptSuffix
7191 ] ) ;
92+ this . addScriptToIndex ( src ) ;
7293} ;
7394
74- Generator . prototype . testTemplate = function ( src , dest ) {
95+ Generator . prototype . testTemplate = function ( src ) {
7596 yeoman . generators . Base . prototype . template . apply ( this , [
7697 src + this . scriptSuffix ,
77- path . join ( this . env . options . testPath , dest ) + this . scriptSuffix
98+ path . join ( this . env . options . testPath , this . _dest ( src ) ) + this . scriptSuffix
7899 ] ) ;
79100} ;
80101
81- Generator . prototype . htmlTemplate = function ( src , dest ) {
102+ Generator . prototype . htmlTemplate = function ( src ) {
82103 yeoman . generators . Base . prototype . template . apply ( this , [
83104 src ,
84- path . join ( this . env . options . appPath , dest )
105+ path . join ( this . env . options . appPath , this . _dest ( src ) )
85106 ] ) ;
86107} ;
87108
88- Generator . prototype . addScriptToIndex = function ( script ) {
109+ Generator . prototype . addScriptToIndex = function ( src ) {
89110 try {
90111 var appPath = this . env . options . appPath ;
91112 var fullPath = path . join ( appPath , 'index.html' ) ;
92113 angularUtils . rewriteFile ( {
93114 file : fullPath ,
94115 needle : '<!-- endbuild -->' ,
95116 splicable : [
96- '<script src="scripts/ ' + script + '.js"></script>'
117+ '<script src="' + this . _dest ( src ) + '.js"></script>'
97118 ]
98119 } ) ;
99120 } catch ( e ) {
100- console . log ( '\nUnable to find ' . yellow + fullPath + '. Reference to ' . yellow + script + '.js ' + 'not added.\n' . yellow ) ;
121+ console . log ( '\nUnable to find ' . yellow + fullPath + '. Reference to ' . yellow + this . _dest ( src ) + '.js ' + 'not added.\n' . yellow ) ;
101122 }
102123} ;
0 commit comments