@@ -65,15 +65,24 @@ export default Command.extend({
65
65
'<schematic>'
66
66
] ,
67
67
68
- getCollectionName ( rawArgs : string [ ] ) {
68
+ getCollectionName ( rawArgs : string [ ] , parsedOptions ?: { collection ?: string } ) : [ string , string ] {
69
+ let schematicName = rawArgs [ 0 ] ;
69
70
let collectionName = CliConfig . getValue ( 'defaults.schematics.collection' ) ;
70
- if ( rawArgs ) {
71
+
72
+ if ( schematicName . match ( / : / ) ) {
73
+ [ collectionName , schematicName ] = schematicName . split ( ':' , 2 ) ;
74
+ } else if ( parsedOptions ) {
75
+ if ( parsedOptions . collection ) {
76
+ collectionName = parsedOptions . collection ;
77
+ }
78
+ } else {
71
79
const parsedArgs = this . parseArgs ( rawArgs , false ) ;
72
80
if ( parsedArgs . options . collection ) {
73
81
collectionName = parsedArgs . options . collection ;
74
82
}
75
83
}
76
- return collectionName ;
84
+
85
+ return [ collectionName , schematicName ] ;
77
86
} ,
78
87
79
88
beforeRun : function ( rawArgs : string [ ] ) {
@@ -83,7 +92,7 @@ export default Command.extend({
83
92
return ;
84
93
}
85
94
86
- const schematicName = rawArgs [ 0 ] ;
95
+ const [ collectionName , schematicName ] = this . getCollectionName ( rawArgs ) ;
87
96
if ( ! schematicName ) {
88
97
return Promise . reject ( new SilentError ( oneLine `
89
98
The "ng generate" command requires a
@@ -103,7 +112,6 @@ export default Command.extend({
103
112
ui : this . ui ,
104
113
project : this . project
105
114
} ) ;
106
- const collectionName = this . getCollectionName ( rawArgs ) ;
107
115
108
116
return getOptionsTask . run ( {
109
117
schematicName,
@@ -166,7 +174,7 @@ export default Command.extend({
166
174
: commandOptions . path ;
167
175
168
176
const cwd = this . project . root ;
169
- const schematicName = rawArgs [ 0 ] ;
177
+ const [ collectionName , schematicName ] = this . getCollectionName ( rawArgs , commandOptions ) ;
170
178
171
179
if ( [ 'component' , 'c' , 'directive' , 'd' ] . indexOf ( schematicName ) !== - 1 ) {
172
180
if ( commandOptions . prefix === undefined ) {
@@ -185,8 +193,6 @@ export default Command.extend({
185
193
ui : this . ui ,
186
194
project : this . project
187
195
} ) ;
188
- const collectionName = commandOptions . collection ||
189
- CliConfig . getValue ( 'defaults.schematics.collection' ) ;
190
196
191
197
if ( collectionName === '@schematics/angular' && schematicName === 'interface' && rawArgs [ 2 ] ) {
192
198
commandOptions . type = rawArgs [ 2 ] ;
0 commit comments