forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'environment-source' of https://github.com/jsanchezgarci…
…a/angular-cli into environment-source * 'environment-source' of https://github.com/jsanchezgarcia/angular-cli: fix(serve): fallback to config.app[0].index (angular#3813)
- Loading branch information
Showing
3 changed files
with
43 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
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 () { | ||
// 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>Loading...<\/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-cli.json', configJson => { | ||
const app = configJson['apps'][0]; | ||
app['index'] = 'not-index.html'; | ||
})) | ||
.then(() => ngServe()) | ||
.then(() => request('http://localhost:4200/')) | ||
.then(body => { | ||
if (!body.match(/<app-root>Loading...<\/app-root>/)) { | ||
throw new Error('Response does not match expected value.'); | ||
} | ||
}) | ||
.then(() => killAllProcesses(), (err) => { killAllProcesses(); throw err; }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters