-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Expand file tree
/
Copy pathrebuild-symlink.ts
More file actions
41 lines (34 loc) · 1.39 KB
/
rebuild-symlink.ts
File metadata and controls
41 lines (34 loc) · 1.39 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
31
32
33
34
35
36
37
38
39
40
41
import { symlink } from 'node:fs/promises';
import { resolve } from 'node:path';
import { appendToFile, expectFileToMatch, writeMultipleFiles } from '../../utils/fs';
import { execAndWaitForOutputToMatch, waitForAnyProcessOutputToMatch } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';
import { getGlobalVariable } from '../../utils/env';
const buildReadyRegEx = getGlobalVariable('argv')['esbuild']
? /Application bundle generation complete\./
: /Build at: /;
export default async function () {
// TODO: Disabled pending investigation. Steps work outside of test
if (getGlobalVariable('argv')['esbuild']) {
return;
}
await updateJsonFile('angular.json', (configJson) => {
configJson.projects['test-project'].architect.build.options.preserveSymlinks = true;
});
await writeMultipleFiles({
'src/link-source.ts': '// empty file',
'src/main.ts': `import './link-dest';`,
});
await symlink(resolve('src/link-source.ts'), resolve('src/link-dest.ts'));
await execAndWaitForOutputToMatch(
'ng',
['build', '--watch', '--configuration=development'],
buildReadyRegEx,
);
// Trigger a rebuild
await Promise.all([
waitForAnyProcessOutputToMatch(buildReadyRegEx),
appendToFile('src/link-source.ts', `\nconsole.log('foo-bar');`),
]);
await expectFileToMatch('dist/test-project/browser/main.js', `console.log('foo-bar')`);
}