File tree 4 files changed +32
-1
lines changed
packages/schematics/angular/ng-new
4 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import {
15
15
empty ,
16
16
mergeWith ,
17
17
move ,
18
+ noop ,
18
19
schematic ,
19
20
} from '@angular-devkit/schematics' ;
20
21
import {
@@ -60,7 +61,7 @@ export default function (options: NgNewOptions): Rule {
60
61
mergeWith (
61
62
apply ( empty ( ) , [
62
63
schematic ( 'workspace' , workspaceOptions ) ,
63
- schematic ( 'application' , applicationOptions ) ,
64
+ options . empty ? noop : schematic ( 'application' , applicationOptions ) ,
64
65
move ( options . directory || options . name ) ,
65
66
] ) ,
66
67
) ,
Original file line number Diff line number Diff line change @@ -56,4 +56,24 @@ describe('Ng New Schematic', () => {
56
56
const moduleContent = tree . readContent ( '/foo/src/app/app.module.ts' ) ;
57
57
expect ( moduleContent ) . toMatch ( / d e c l a r a t i o n s : \s * \[ \s * A p p C o m p o n e n t \s * \] / m) ;
58
58
} ) ;
59
+
60
+ fdescribe ( 'empty option' , ( ) => {
61
+ it ( 'should create an empty workspace' , ( ) => {
62
+ const options = { ...defaultOptions , empty : true } ;
63
+
64
+ const tree = schematicRunner . runSchematic ( 'ng-new' , options ) ;
65
+ const files = tree . files ;
66
+ expect ( files . indexOf ( '/bar/angular.json' ) ) . toBeGreaterThanOrEqual ( 0 ) ;
67
+ } ) ;
68
+
69
+ it ( 'should not create a project' , ( ) => {
70
+ const options = { ...defaultOptions , empty : true } ;
71
+
72
+ const tree = schematicRunner . runSchematic ( 'ng-new' , options ) ;
73
+ const files = tree . files ;
74
+ expect ( files . indexOf ( '/bar/src' ) ) . toBe ( - 1 ) ;
75
+ } ) ;
76
+
77
+
78
+ } ) ;
59
79
} ) ;
Original file line number Diff line number Diff line change @@ -72,4 +72,8 @@ export interface Schema {
72
72
* Skip creating spec files.
73
73
*/
74
74
skipTests ?: boolean ;
75
+ /**
76
+ * Create an empty workspace with no projects.
77
+ */
78
+ empty ?: boolean ;
75
79
}
Original file line number Diff line number Diff line change 131
131
"type" : " boolean" ,
132
132
"default" : false ,
133
133
"alias" : " S"
134
+ },
135
+ "empty" : {
136
+ "description" : " Create an empty workspace with no projects." ,
137
+ "type" : " boolean" ,
138
+ "default" : false ,
139
+ "alias" : " e"
134
140
}
135
141
},
136
142
"required" : [
You can’t perform that action at this time.
0 commit comments