File tree Expand file tree Collapse file tree 4 files changed +24
-0
lines changed
packages/schematics/angular/universal Expand file tree Collapse file tree 4 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,9 @@ import {
25
25
template ,
26
26
url ,
27
27
} from '@angular-devkit/schematics' ;
28
+ import {
29
+ NodePackageInstallTask ,
30
+ } from '@angular-devkit/schematics/tasks' ;
28
31
import * as ts from 'typescript' ;
29
32
import { findNode , getDecoratorMetadata } from '../utility/ast-utils' ;
30
33
import { InsertChange } from '../utility/change' ;
@@ -208,6 +211,11 @@ export default function (options: UniversalOptions): Rule {
208
211
const clientArchitect = getClientArchitect ( host , options ) ;
209
212
const outDir = getTsConfigOutDir ( host , clientArchitect ) ;
210
213
const tsConfigExtends = basename ( clientArchitect . build . options . tsConfig ) ;
214
+
215
+ if ( ! options . skipInstall ) {
216
+ context . addTask ( new NodePackageInstallTask ( ) ) ;
217
+ }
218
+
211
219
const templateSource = apply ( url ( './files' ) , [
212
220
template ( {
213
221
...strings ,
Original file line number Diff line number Diff line change @@ -109,4 +109,11 @@ describe('Universal Schematic', () => {
109
109
const contents = tree . readContent ( filePath ) ;
110
110
expect ( contents ) . toMatch ( / d o c u m e n t .a d d E v e n t L i s t e n e r \( ' D O M C o n t e n t L o a d e d ' , \( \) = > { / ) ;
111
111
} ) ;
112
+
113
+ it ( 'should install npm dependencies' , ( ) => {
114
+ schematicRunner . runSchematic ( 'universal' , defaultOptions , appTree ) ;
115
+ expect ( schematicRunner . tasks . length ) . toBe ( 1 ) ;
116
+ expect ( schematicRunner . tasks [ 0 ] . name ) . toBe ( 'node-package' ) ;
117
+ expect ( ( schematicRunner . tasks [ 0 ] . options as { command : string } ) . command ) . toBe ( 'install' ) ;
118
+ } ) ;
112
119
} ) ;
Original file line number Diff line number Diff line change @@ -43,4 +43,8 @@ export interface Schema {
43
43
* The name of the root module class.
44
44
*/
45
45
rootModuleClassName ?: string ;
46
+ /**
47
+ * Skip installing dependency packages.
48
+ */
49
+ skipInstall ?: boolean ;
46
50
}
Original file line number Diff line number Diff line change 52
52
"type" : " string" ,
53
53
"description" : " The name of the root module class." ,
54
54
"default" : " AppServerModule"
55
+ },
56
+ "skipInstall" : {
57
+ "description" : " Skip installing dependency packages." ,
58
+ "type" : " boolean" ,
59
+ "default" : false
55
60
}
56
61
},
57
62
"required" : [
You can’t perform that action at this time.
0 commit comments