-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Expand file tree
/
Copy pathrun.ts
More file actions
28 lines (24 loc) · 1.13 KB
/
run.ts
File metadata and controls
28 lines (24 loc) · 1.13 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
import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import { getGlobalVariable } from '../../utils/env';
import { silentNg } from '../../utils/process';
const OUTPUT_INDEX_PATH = 'dist/test-project/browser/index.html';
export default async function () {
// Development build
await silentNg('run', 'test-project:build:development');
// Output index HTML file should reference main JS file
const devIndexContent = await readFile(OUTPUT_INDEX_PATH, 'utf-8');
assert.match(devIndexContent, /main\.js/);
const usingApplicationBuilder = getGlobalVariable('argv')['esbuild'];
// Production build
await silentNg('run', 'test-project:build');
// Output index HTML file should reference main JS file with hashing
const prodIndexContent = await readFile(OUTPUT_INDEX_PATH, 'utf-8');
if (usingApplicationBuilder) {
// application builder uses an 8 character hash and a dash as a separator
assert.match(prodIndexContent, /main-[a-zA-Z0-9]{8}\.js/);
} else {
// browser builder uses a 16 character hash and a period as a separator
assert.match(prodIndexContent, /main\.[a-zA-Z0-9]{16}\.js/);
}
}