forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfallback.ts
More file actions
35 lines (32 loc) · 1.37 KB
/
fallback.ts
File metadata and controls
35 lines (32 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { request } from '../../utils/http';
import { killAllProcesses } from '../../utils/process';
import { ngServe } from '../../utils/project';
import { updateJsonFile } from '../../utils/project';
import { moveFile } from '../../utils/fs';
export default function () {
// TODO(architect): Delete this test. It is now in devkit/build-angular.
// should fallback to config.app[0].index (index.html by default)
return Promise.resolve()
.then(() => ngServe())
.then(() => request('http://localhost:4200/'))
.then(body => {
if (!body.match(/<app-root><\/app-root>/)) {
throw new Error('Response does not match expected value.');
}
})
.then(() => killAllProcesses(), (err) => { killAllProcesses(); throw err; })
// should correctly fallback to a changed index
.then(() => moveFile('src/index.html', 'src/not-index.html'))
.then(() => updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.build.options.index = 'src/not-index.html';
}))
.then(() => ngServe())
.then(() => request('http://localhost:4200/'))
.then(body => {
if (!body.match(/<app-root><\/app-root>/)) {
throw new Error('Response does not match expected value.');
}
})
.then(() => killAllProcesses(), (err) => { killAllProcesses(); throw err; });
}