This repository was archived by the owner on Nov 22, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +56
-24
lines changed
express-engine/schematics/install
hapi-engine/schematics/install Expand file tree Collapse file tree 4 files changed +56
-24
lines changed Original file line number Diff line number Diff line change @@ -72,4 +72,14 @@ describe('Universal Schematic', () => {
7272 const content = tree . readContent ( '/projects/test-app/server.ts' ) ;
7373 expect ( content ) . toContain ( `export * from './src/main.server'` ) ;
7474 } ) ;
75+
76+ it ( `should add correct value to 'distFolder'` , async ( ) => {
77+ const tree = await schematicRunner
78+ . runSchematicAsync ( 'ng-add' , defaultOptions , appTree )
79+ . toPromise ( ) ;
80+
81+ const content = tree . readContent ( '/projects/test-app/server.ts' ) ;
82+ expect ( content )
83+ . toContain ( `const distFolder = join(process.cwd(), 'dist/test-app/browser');` ) ;
84+ } ) ;
7585} ) ;
Original file line number Diff line number Diff line change @@ -54,24 +54,30 @@ function addDependencies(options: UniversalOptions): Rule {
5454 } ;
5555}
5656
57- export default function ( options : UniversalOptions ) : Rule {
58- return async ( host : Tree ) => {
57+ function addServerFile ( options : UniversalOptions ) : Rule {
58+ return async host => {
5959 const clientProject = await getProject ( host , options . clientProject ) ;
6060 const browserDistDirectory = await getOutputPath ( host , options . clientProject , 'build' ) ;
6161
62- const rootSource = apply ( url ( './files' ) , [
63- template ( {
64- ...strings ,
65- ...options ,
66- stripTsExtension,
67- browserDistDirectory,
68- } ) ,
69- move ( clientProject . root )
70- ] ) ;
62+ return mergeWith (
63+ apply ( url ( './files' ) , [
64+ template ( {
65+ ...strings ,
66+ ...options ,
67+ stripTsExtension,
68+ browserDistDirectory,
69+ } ) ,
70+ move ( clientProject . root )
71+ ] )
72+ ) ;
73+ } ;
74+ }
7175
76+ export default function ( options : UniversalOptions ) : Rule {
77+ return ( ) => {
7278 return chain ( [
73- mergeWith ( rootSource ) ,
7479 addUniversalCommonRule ( options ) ,
80+ addServerFile ( options ) ,
7581 addDependencies ( options ) ,
7682 ] ) ;
7783 } ;
Original file line number Diff line number Diff line change @@ -72,4 +72,14 @@ describe('Universal Schematic', () => {
7272 const content = tree . readContent ( '/projects/test-app/server.ts' ) ;
7373 expect ( content ) . toContain ( `export * from './src/main.server'` ) ;
7474 } ) ;
75+
76+ it ( `should add correct value to 'distFolder'` , async ( ) => {
77+ const tree = await schematicRunner
78+ . runSchematicAsync ( 'ng-add' , defaultOptions , appTree )
79+ . toPromise ( ) ;
80+
81+ const content = tree . readContent ( '/projects/test-app/server.ts' ) ;
82+ expect ( content )
83+ . toContain ( `const distFolder = join(process.cwd(), 'dist/test-app/browser');` ) ;
84+ } ) ;
7585} ) ;
Original file line number Diff line number Diff line change @@ -59,24 +59,30 @@ function addDependencies(options: UniversalOptions): Rule {
5959 } ;
6060}
6161
62- export default function ( options : UniversalOptions ) : Rule {
63- return async ( host : Tree ) => {
62+ function addServerFile ( options : UniversalOptions ) : Rule {
63+ return async host => {
6464 const clientProject = await getProject ( host , options . clientProject ) ;
6565 const browserDistDirectory = await getOutputPath ( host , options . clientProject , 'build' ) ;
6666
67- const rootSource = apply ( url ( './files' ) , [
68- template ( {
69- ...strings ,
70- ...options ,
71- stripTsExtension,
72- browserDistDirectory,
73- } ) ,
74- move ( clientProject . root )
75- ] ) ;
67+ return mergeWith (
68+ apply ( url ( './files' ) , [
69+ template ( {
70+ ...strings ,
71+ ...options ,
72+ stripTsExtension,
73+ browserDistDirectory,
74+ } ) ,
75+ move ( clientProject . root )
76+ ] )
77+ ) ;
78+ } ;
79+ }
7680
81+ export default function ( options : UniversalOptions ) : Rule {
82+ return ( ) => {
7783 return chain ( [
78- mergeWith ( rootSource ) ,
7984 addUniversalCommonRule ( options ) ,
85+ addServerFile ( options ) ,
8086 addDependencies ( options ) ,
8187 ] ) ;
8288 } ;
You can’t perform that action at this time.
0 commit comments