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
30 lines (26 loc) · 1.29 KB
/
prod-build.ts
File metadata and controls
30 lines (26 loc) · 1.29 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
import {join} from 'path';
import {readdirSync} from 'fs';
import {expectFileToExist, expectFileToMatch} from '../../utils/fs';
import {ng} from '../../utils/process';
import {expectGitToBeClean} from '../../utils/git';
import {getGlobalVariable} from '../../utils/env';
export default function() {
// TODO(architect): Delete this test. It is now in devkit/build-angular.
// Skip this in ejected tests.
const ejected = getGlobalVariable('argv').eject;
// 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/test-project/index.html', /main\.[0-9a-f]{20}\.js/))
.then(() => expectFileToMatch('dist/test-project/index.html', /styles\.[0-9a-f]{20}\.css/))
.then(() => expectFileToMatch('dist/test-project/3rdpartylicenses.txt', /MIT/))
// Defaults to AoT
.then(() => {
const main = readdirSync('./dist/test-project').find(name => !!name.match(/main.[a-z0-9]+\.js/));
expectFileToMatch(`dist/test-project/${main}`, /bootstrapModuleFactory\(/);
})
// Check that the process didn't change local files.
.then(() => !ejected && expectGitToBeClean());
}