File tree Expand file tree Collapse file tree 3 files changed +43
-5
lines changed
packages/angular_devkit/build_angular/src/protractor
tests/legacy-cli/e2e/tests/misc Expand file tree Collapse file tree 3 files changed +43
-5
lines changed Original file line number Diff line number Diff line change @@ -105,10 +105,21 @@ async function execute(
105
105
const serverOptions = await context . getTargetOptions ( target ) ;
106
106
107
107
const overrides : Record < string , string | number | boolean > = { watch : false } ;
108
- if ( options . host !== undefined ) { overrides . host = options . host ; }
109
- if ( options . port !== undefined ) { overrides . port = options . port ; }
110
- server = await context . scheduleTarget ( target , overrides ) ;
108
+ if ( options . host !== undefined ) {
109
+ overrides . host = options . host ;
110
+ } else if ( typeof serverOptions . host === 'string' ) {
111
+ options . host = serverOptions . host ;
112
+ } else {
113
+ options . host = overrides . host = 'localhost' ;
114
+ }
111
115
116
+ if ( options . port !== undefined ) {
117
+ overrides . port = options . port ;
118
+ } else if ( typeof serverOptions . port === 'number' ) {
119
+ options . port = serverOptions . port ;
120
+ }
121
+
122
+ server = await context . scheduleTarget ( target , overrides ) ;
112
123
let result ;
113
124
try {
114
125
result = await server . result ;
Original file line number Diff line number Diff line change 41
41
},
42
42
"host" : {
43
43
"type" : " string" ,
44
- "description" : " Host to listen on." ,
45
- "default" : " localhost"
44
+ "description" : " Host to listen on."
46
45
},
47
46
"baseUrl" : {
48
47
"type" : " string" ,
Original file line number Diff line number Diff line change
1
+ import * as os from 'os' ;
2
+ import { killAllProcesses , ng } from '../../utils/process' ;
3
+ import { updateJsonFile } from '../../utils/project' ;
4
+
5
+ export default async function ( ) {
6
+ const interfaces = [ ] . concat . apply ( [ ] , Object . values ( os . networkInterfaces ( ) ) ) ;
7
+ let host = '' ;
8
+ for ( const { family, address, internal } of interfaces ) {
9
+ if ( family === 'IPv4' && ! internal ) {
10
+ host = address ;
11
+ break ;
12
+ }
13
+ }
14
+
15
+ try {
16
+ await updateJsonFile ( 'angular.json' , workspaceJson => {
17
+ const appArchitect = workspaceJson . projects [ 'test-project' ] . architect ;
18
+ appArchitect . serve . options . port = 8888 ;
19
+ appArchitect . serve . options . host = host ;
20
+ } ) ;
21
+
22
+ await ng ( 'e2e' ) ;
23
+
24
+ await ng ( 'e2e' , '--host' , host ) ;
25
+ } finally {
26
+ await killAllProcesses ( ) ;
27
+ }
28
+ }
You can’t perform that action at this time.
0 commit comments