1
1
import assert from 'node:assert' ;
2
- import { setTimeout } from 'node:timers/promises' ;
3
- import { ng , waitForAnyProcessOutputToMatch } from '../../utils/process' ;
2
+ import {
3
+ execAndWaitForOutputToMatch ,
4
+ ng ,
5
+ waitForAnyProcessOutputToMatch ,
6
+ } from '../../utils/process' ;
4
7
import { installWorkspacePackages , uninstallPackage } from '../../utils/packages' ;
5
- import { ngServe , useSha } from '../../utils/project' ;
8
+ import { useSha } from '../../utils/project' ;
6
9
import { getGlobalVariable } from '../../utils/env' ;
7
10
import { readFile , writeFile } from '../../utils/fs' ;
11
+ import { findFreePort } from '../../utils/network' ;
8
12
9
13
export default async function ( ) {
10
14
assert (
@@ -22,20 +26,27 @@ export default async function () {
22
26
await useSha ( ) ;
23
27
await installWorkspacePackages ( ) ;
24
28
25
- const port = await ngServe ( ) ;
29
+ const port = await findFreePort ( ) ;
30
+ await execAndWaitForOutputToMatch (
31
+ 'ng' ,
32
+ [ 'serve' , '--port' , port . toString ( ) ] ,
33
+ / A p p l i c a t i o n b u n d l e g e n e r a t i o n c o m p l e t e / ,
34
+ { CI : '0' , NO_COLOR : 'true' } ,
35
+ ) ;
26
36
await validateResponse ( '/' , / H e l l o , / ) ;
27
37
28
- const appConfigContentsUpdated = `
29
- import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
30
- ${ ( await readFile ( 'src/app/app.config.ts' ) ) . replace ( 'provideRouter(routes),' , 'provideAnimationsAsync(), provideRouter(routes),' ) }
31
- ` ;
32
-
33
38
await Promise . all ( [
34
39
waitForAnyProcessOutputToMatch (
35
40
/ n e w d e p e n d e n c i e s o p t i m i z e d : @ a n g u l a r \/ p l a t f o r m - b r o w s e r \/ a n i m a t i o n s \/ a s y n c / ,
36
41
6000 ,
37
42
) ,
38
- setTimeout ( 200 ) . then ( ( ) => writeFile ( 'src/app/app.config.ts' , appConfigContentsUpdated ) ) ,
43
+ writeFile (
44
+ 'src/app/app.config.ts' ,
45
+ `
46
+ import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
47
+ ${ ( await readFile ( 'src/app/app.config.ts' ) ) . replace ( 'provideRouter(routes),' , 'provideAnimationsAsync(), provideRouter(routes),' ) }
48
+ ` ,
49
+ ) ,
39
50
] ) ;
40
51
41
52
// Verify the app still works.
0 commit comments