@@ -8,40 +8,31 @@ var chalk = require('chalk');
8
8
var Generator = module . exports = function Generator ( ) {
9
9
yeoman . generators . NamedBase . apply ( this , arguments ) ;
10
10
11
+ var bowerJson = { } ;
12
+
11
13
try {
12
- this . appname = require ( path . join ( process . cwd ( ) , 'bower.json' ) ) . name ;
13
- } catch ( e ) {
14
+ bowerJson = require ( path . join ( process . cwd ( ) , 'bower.json' ) ) ;
15
+ } catch ( e ) { }
16
+
17
+ if ( bowerJson . name ) {
18
+ this . appname = bowerJson . name ;
19
+ } else {
14
20
this . appname = path . basename ( process . cwd ( ) ) ;
15
21
}
16
- this . appname = this . _ . slugify ( this . _ . humanize ( this . appname ) ) ;
17
22
18
- try {
19
- this . scriptAppName = require ( path . join ( process . cwd ( ) , 'bower.json' ) ) . moduleName ;
20
- } catch ( e ) { }
23
+ this . appname = this . _ . slugify ( this . _ . humanize ( this . appname ) ) ;
21
24
22
- this . scriptAppName = this . scriptAppName || this . _ . camelize ( this . appname ) + angularUtils . appName ( this ) ;
25
+ this . scriptAppName = bowerJson . moduleName || this . _ . camelize ( this . appname ) + angularUtils . appName ( this ) ;
23
26
24
27
this . cameledName = this . _ . camelize ( this . name ) ;
25
28
this . classedName = this . _ . classify ( this . name ) ;
26
29
27
30
if ( typeof this . env . options . appPath === 'undefined' ) {
28
- this . env . options . appPath = this . options . appPath ;
29
-
30
- if ( ! this . env . options . appPath ) {
31
- try {
32
- this . env . options . appPath = require ( path . join ( process . cwd ( ) , 'bower.json' ) ) . appPath ;
33
- } catch ( e ) { }
34
- }
35
- this . env . options . appPath = this . env . options . appPath || 'app' ;
31
+ this . env . options . appPath = this . options . appPath || bowerJson . appPath || 'app' ;
36
32
this . options . appPath = this . env . options . appPath ;
37
33
}
38
34
39
- if ( typeof this . env . options . testPath === 'undefined' ) {
40
- try {
41
- this . env . options . testPath = require ( path . join ( process . cwd ( ) , 'bower.json' ) ) . testPath ;
42
- } catch ( e ) { }
43
- this . env . options . testPath = this . env . options . testPath || 'test/spec' ;
44
- }
35
+ this . env . options . testPath = this . env . options . testPath || bowerJson . testPath || 'test/spec' ;
45
36
46
37
this . env . options . coffee = this . options . coffee ;
47
38
if ( typeof this . env . options . coffee === 'undefined' ) {
0 commit comments