@@ -42,6 +42,14 @@ var Generator = module.exports = function Generator() {
4242 this . env . options . testPath = this . env . options . testPath || 'test/spec' ;
4343 }
4444
45+ //Test if script module name is set. Use this for the script files otherwise, just use the name of the app
46+ if ( typeof this . env . options . scriptModuleName === 'undefined' ) {
47+ try {
48+ this . env . options . scriptModuleName = require ( path . join ( process . cwd ( ) , 'bower.json' ) ) . scriptModuleName ;
49+ } catch ( e ) { }
50+ this . env . options . scriptModuleName = this . env . options . scriptModuleName || this . name . toLowerCase ( ) ;
51+ }
52+
4553 this . env . options . coffee = this . options . coffee ;
4654 if ( typeof this . env . options . coffee === 'undefined' ) {
4755 this . option ( 'coffee' ) ;
@@ -117,10 +125,10 @@ Generator.prototype.addScriptToIndex = function (script) {
117125} ;
118126
119127Generator . prototype . generateSourceAndTest = function ( appTemplate , testTemplate , targetDirectory , skipAdd ) {
120-
121- this . appTemplate ( appTemplate , path . join ( 'scripts' , targetDirectory , this . name ) ) ;
122- this . testTemplate ( testTemplate , path . join ( targetDirectory , this . name ) ) ;
128+ var dir = this . env . options . scriptModuleName + '/' + targetDirectory ;
129+ this . appTemplate ( appTemplate , path . join ( 'scripts' , dir , this . name ) ) ;
130+ this . testTemplate ( testTemplate , path . join ( dir , this . name ) ) ;
123131 if ( ! skipAdd ) {
124- this . addScriptToIndex ( path . join ( targetDirectory , this . name ) ) ;
132+ this . addScriptToIndex ( path . join ( dir , this . name ) ) ;
125133 }
126134} ;
0 commit comments