File tree Expand file tree Collapse file tree 9 files changed +117
-20
lines changed
Expand file tree Collapse file tree 9 files changed +117
-20
lines changed Original file line number Diff line number Diff line change 1+ Description:
2+ Creates a new AngularJS service.
3+ Docs: http://docs.angularjs.org/guide/dev_guide.services.creating_services
4+
5+ Example:
6+ yo angular:constant thing [--coffee] [--minsafe]
7+
8+ This will create:
9+ app/scripts/services/thing.js
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ var path = require ( 'path' ) ;
3+ var util = require ( 'util' ) ;
4+ var ScriptBase = require ( '../script-base.js' ) ;
5+ var angularUtils = require ( '../util.js' ) ;
6+
7+
8+ module . exports = Generator ;
9+
10+ function Generator ( ) {
11+ ScriptBase . apply ( this , arguments ) ;
12+ }
13+
14+ util . inherits ( Generator , ScriptBase ) ;
15+
16+ Generator . prototype . createServiceFiles = function createServiceFiles ( ) {
17+ this . appTemplate ( 'service/constant' , 'scripts/services/' + this . name ) ;
18+ this . testTemplate ( 'spec/service' , 'services/' + this . name ) ;
19+ this . addScriptToIndex ( 'services/' + this . name ) ;
20+ } ;
Original file line number Diff line number Diff line change 1+ Description:
2+ Creates a new AngularJS service.
3+ Docs: http://docs.angularjs.org/guide/dev_guide.services.creating_services
4+
5+ Example:
6+ yo angular:factory thing [--coffee] [--minsafe]
7+
8+ This will create:
9+ app/scripts/services/thing.js
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ var path = require ( 'path' ) ;
3+ var util = require ( 'util' ) ;
4+ var ScriptBase = require ( '../script-base.js' ) ;
5+ var angularUtils = require ( '../util.js' ) ;
6+
7+
8+ module . exports = Generator ;
9+
10+ function Generator ( ) {
11+ ScriptBase . apply ( this , arguments ) ;
12+ }
13+
14+ util . inherits ( Generator , ScriptBase ) ;
15+
16+ Generator . prototype . createServiceFiles = function createServiceFiles ( ) {
17+ this . appTemplate ( 'service/factory' , 'scripts/services/' + this . name ) ;
18+ this . testTemplate ( 'spec/service' , 'services/' + this . name ) ;
19+ this . addScriptToIndex ( 'services/' + this . name ) ;
20+ } ;
Original file line number Diff line number Diff line change 1+ Description:
2+ Creates a new AngularJS service.
3+ Docs: http://docs.angularjs.org/guide/dev_guide.services.creating_services
4+
5+ Example:
6+ yo angular:provider thing [--coffee] [--minsafe]
7+
8+ This will create:
9+ app/scripts/services/thing.js
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ var path = require ( 'path' ) ;
3+ var util = require ( 'util' ) ;
4+ var ScriptBase = require ( '../script-base.js' ) ;
5+ var angularUtils = require ( '../util.js' ) ;
6+
7+
8+ module . exports = Generator ;
9+
10+ function Generator ( ) {
11+ ScriptBase . apply ( this , arguments ) ;
12+ }
13+
14+ util . inherits ( Generator , ScriptBase ) ;
15+
16+ Generator . prototype . createServiceFiles = function createServiceFiles ( ) {
17+ this . appTemplate ( 'service/provider' , 'scripts/services/' + this . name ) ;
18+ this . testTemplate ( 'spec/service' , 'services/' + this . name ) ;
19+ this . addScriptToIndex ( 'services/' + this . name ) ;
20+ } ;
Original file line number Diff line number Diff line change @@ -9,31 +9,12 @@ module.exports = Generator;
99
1010function Generator ( ) {
1111 ScriptBase . apply ( this , arguments ) ;
12-
13- var allowedTypes = [
14- 'constant' ,
15- 'factory' ,
16- 'provider' ,
17- 'service' ,
18- 'value'
19- ] ;
20-
21- this . argument ( 'type' , {
22- type : String ,
23- defaults : 'factory' ,
24- banner : '[type]' ,
25- required : false
26- } ) ;
27-
28- if ( allowedTypes . indexOf ( this . type ) === - 1 ) {
29- this . type = 'factory' ;
30- }
3112}
3213
3314util . inherits ( Generator , ScriptBase ) ;
3415
3516Generator . prototype . createServiceFiles = function createServiceFiles ( ) {
36- this . appTemplate ( path . join ( 'service' , this . type ) , 'scripts/services/' + this . name ) ;
17+ this . appTemplate ( 'service/service' , 'scripts/services/' + this . name ) ;
3718 this . testTemplate ( 'spec/service' , 'services/' + this . name ) ;
3819 this . addScriptToIndex ( 'services/' + this . name ) ;
3920} ;
Original file line number Diff line number Diff line change 1+ Description:
2+ Creates a new AngularJS service.
3+ Docs: http://docs.angularjs.org/guide/dev_guide.services.creating_services
4+
5+ Example:
6+ yo angular:value thing [--coffee] [--minsafe]
7+
8+ This will create:
9+ app/scripts/services/thing.js
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ var path = require ( 'path' ) ;
3+ var util = require ( 'util' ) ;
4+ var ScriptBase = require ( '../script-base.js' ) ;
5+ var angularUtils = require ( '../util.js' ) ;
6+
7+
8+ module . exports = Generator ;
9+
10+ function Generator ( ) {
11+ ScriptBase . apply ( this , arguments ) ;
12+ }
13+
14+ util . inherits ( Generator , ScriptBase ) ;
15+
16+ Generator . prototype . createServiceFiles = function createServiceFiles ( ) {
17+ this . appTemplate ( 'service/constant' , 'scripts/services/' + this . name ) ;
18+ this . testTemplate ( 'spec/service' , 'services/' + this . name ) ;
19+ this . addScriptToIndex ( 'services/' + this . name ) ;
20+ } ;
You can’t perform that action at this time.
0 commit comments