|
1 |
| -import {join} from 'path'; |
2 |
| -import {readdirSync} from 'fs'; |
3 |
| -import {expectFileToExist, expectFileToMatch} from '../../utils/fs'; |
4 |
| -import {ng} from '../../utils/process'; |
5 |
| -import {expectGitToBeClean} from '../../utils/git'; |
| 1 | +import { readdirSync } from 'fs'; |
| 2 | +import { join } from 'path'; |
| 3 | +import { getGlobalVariable } from '../../utils/env'; |
| 4 | +import { expectFileToExist, expectFileToMatch } from '../../utils/fs'; |
| 5 | +import { expectGitToBeClean } from '../../utils/git'; |
| 6 | +import { ng } from '../../utils/process'; |
6 | 7 |
|
7 | 8 |
|
8 |
| -export default function() { |
| 9 | +export default async function () { |
9 | 10 | // TODO(architect): Delete this test. It is now in devkit/build-angular.
|
10 | 11 |
|
11 | 12 | // Can't use the `ng` helper because somewhere the environment gets
|
12 | 13 | // stuck to the first build done
|
13 |
| - return ng('build', '--prod') |
14 |
| - .then(() => expectFileToExist(join(process.cwd(), 'dist'))) |
15 |
| - // Check for cache busting hash script src |
16 |
| - .then(() => expectFileToMatch('dist/test-project/index.html', /main-es5\.[0-9a-f]{20}\.js/)) |
17 |
| - .then(() => expectFileToMatch('dist/test-project/index.html', /main-es2015\.[0-9a-f]{20}\.js/)) |
18 |
| - .then(() => expectFileToMatch('dist/test-project/index.html', /styles\.[0-9a-f]{20}\.css/)) |
19 |
| - .then(() => expectFileToMatch('dist/test-project/3rdpartylicenses.txt', /MIT/)) |
20 |
| - // Defaults to AoT |
21 |
| - .then(() => { |
22 |
| - const mainES5 = readdirSync('./dist/test-project').find(name => !!name.match(/main-es5.[a-z0-9]+\.js/)); |
23 |
| - expectFileToMatch(`dist/test-project/${mainES5}`, /bootstrapModuleFactory\(/); |
| 14 | + const argv = getGlobalVariable('argv'); |
| 15 | + const ivyProject = argv['ivy']; |
| 16 | + const bootstrapRegExp = ivyProject |
| 17 | + ? /bootstrapModule\([a-zA-Z]+\)\./ |
| 18 | + : /bootstrapModuleFactory\([a-zA-Z]+\)\./; |
24 | 19 |
|
25 |
| - const mainES2015 = readdirSync('./dist/test-project').find(name => !!name.match(/main-es2015.[a-z0-9]+\.js/)); |
26 |
| - expectFileToMatch(`dist/test-project/${mainES5}`, /bootstrapModuleFactory\(/); |
27 |
| - }) |
28 |
| - // Check that the process didn't change local files. |
29 |
| - .then(() => expectGitToBeClean()); |
| 20 | + await ng('build', '--prod'); |
| 21 | + await expectFileToExist(join(process.cwd(), 'dist')); |
| 22 | + // Check for cache busting hash script src |
| 23 | + await expectFileToMatch('dist/test-project/index.html', /main-es5\.[0-9a-f]{20}\.js/); |
| 24 | + await expectFileToMatch('dist/test-project/index.html', /main-es2015\.[0-9a-f]{20}\.js/); |
| 25 | + await expectFileToMatch('dist/test-project/index.html', /styles\.[0-9a-f]{20}\.css/); |
| 26 | + await expectFileToMatch('dist/test-project/3rdpartylicenses.txt', /MIT/); |
| 27 | + |
| 28 | + const dirContents = readdirSync('./dist/test-project'); |
| 29 | + const mainES5 = dirContents.find(name => /main-es5.[a-z0-9]+\.js/.test(name)); |
| 30 | + await expectFileToMatch(`dist/test-project/${mainES5}`, bootstrapRegExp); |
| 31 | + |
| 32 | + const mainES2015 = dirContents.find(name => /main-es2015.[a-z0-9]+\.js/.test(name)); |
| 33 | + await expectFileToMatch(`dist/test-project/${mainES2015}`, bootstrapRegExp); |
| 34 | + |
| 35 | + // Check that the process didn't change local files. |
| 36 | + await expectGitToBeClean(); |
30 | 37 | }
|
0 commit comments