forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprod-build.ts
More file actions
23 lines (21 loc) · 990 Bytes
/
prod-build.ts
File metadata and controls
23 lines (21 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import {join} from 'path';
import {readdirSync} from 'fs';
import {expectFileToExist, expectFileToMatch} from '../../utils/fs';
import {ng} from '../../utils/process';
import {expectGitToBeClean} from '../../utils/git';
export default function() {
// Can't use the `ng` helper because somewhere the environment gets
// stuck to the first build done
return ng('build', '--prod')
.then(() => expectFileToExist(join(process.cwd(), 'dist')))
// Check for cache busting hash script src
.then(() => expectFileToMatch('dist/index.html', /main\.[0-9a-f]{20}\.bundle\.js/))
.then(() => expectFileToMatch('dist/index.html', /styles\.[0-9a-f]{20}\.bundle\.css/))
// Defaults to AoT
.then(() => {
const main = readdirSync('./dist').find(name => !!name.match(/main.[a-z0-9]+\.bundle\.js/));
expectFileToMatch(`dist/${main}`, /bootstrapModuleFactory\(/);
})
// Check that the process didn't change local files.
.then(() => expectGitToBeClean());
}