mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-20 21:42:38 +08:00
fix(@angular-devkit/build-angular): e2e does not respect dev-server host and port settings (#14165)
Fixes #14151
This commit is contained in:
parent
968204fa2a
commit
16ce92d77a
@ -105,10 +105,21 @@ async function execute(
|
|||||||
const serverOptions = await context.getTargetOptions(target);
|
const serverOptions = await context.getTargetOptions(target);
|
||||||
|
|
||||||
const overrides: Record<string, string | number | boolean> = { watch: false };
|
const overrides: Record<string, string | number | boolean> = { watch: false };
|
||||||
if (options.host !== undefined) { overrides.host = options.host; }
|
if (options.host !== undefined) {
|
||||||
if (options.port !== undefined) { overrides.port = options.port; }
|
overrides.host = options.host;
|
||||||
server = await context.scheduleTarget(target, overrides);
|
} else if (typeof serverOptions.host === 'string') {
|
||||||
|
options.host = serverOptions.host;
|
||||||
|
} else {
|
||||||
|
options.host = overrides.host = 'localhost';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.port !== undefined) {
|
||||||
|
overrides.port = options.port;
|
||||||
|
} else if (typeof serverOptions.port === 'number') {
|
||||||
|
options.port = serverOptions.port;
|
||||||
|
}
|
||||||
|
|
||||||
|
server = await context.scheduleTarget(target, overrides);
|
||||||
let result;
|
let result;
|
||||||
try {
|
try {
|
||||||
result = await server.result;
|
result = await server.result;
|
||||||
|
@ -41,8 +41,7 @@
|
|||||||
},
|
},
|
||||||
"host": {
|
"host": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Host to listen on.",
|
"description": "Host to listen on."
|
||||||
"default": "localhost"
|
|
||||||
},
|
},
|
||||||
"baseUrl": {
|
"baseUrl": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
28
tests/legacy-cli/e2e/tests/misc/e2e-host.ts
Normal file
28
tests/legacy-cli/e2e/tests/misc/e2e-host.ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import * as os from 'os';
|
||||||
|
import { killAllProcesses, ng } from '../../utils/process';
|
||||||
|
import { updateJsonFile } from '../../utils/project';
|
||||||
|
|
||||||
|
export default async function () {
|
||||||
|
const interfaces = [].concat.apply([], Object.values(os.networkInterfaces()));
|
||||||
|
let host = '';
|
||||||
|
for (const { family, address, internal } of interfaces) {
|
||||||
|
if (family === 'IPv4' && !internal) {
|
||||||
|
host = address;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await updateJsonFile('angular.json', workspaceJson => {
|
||||||
|
const appArchitect = workspaceJson.projects['test-project'].architect;
|
||||||
|
appArchitect.serve.options.port = 8888;
|
||||||
|
appArchitect.serve.options.host = host;
|
||||||
|
});
|
||||||
|
|
||||||
|
await ng('e2e');
|
||||||
|
|
||||||
|
await ng('e2e', '--host', host);
|
||||||
|
} finally {
|
||||||
|
await killAllProcesses();
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user