-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Expand file tree
/
Copy pathdisk-cache-purge.ts
More file actions
30 lines (25 loc) · 955 Bytes
/
disk-cache-purge.ts
File metadata and controls
30 lines (25 loc) · 955 Bytes
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 'node:path';
import { createDir, expectFileNotToExist, expectFileToExist, writeFile } from '../../utils/fs';
import { silentNg } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';
export default async function () {
const cachePath = '.angular/cache';
const staleCachePath = join(cachePath, 'v1.0.0');
// No need to include all applications code to verify disk cache existence.
await writeFile('src/main.ts', 'console.log(1);');
// Enable cache for all environments
await updateJsonFile('angular.json', (config) => {
config.cli ??= {};
config.cli.cache = {
environment: 'all',
enabled: true,
path: cachePath,
};
});
// Create a dummy stale disk cache directory.
await createDir(staleCachePath);
await expectFileToExist(staleCachePath);
await silentNg('build');
await expectFileToExist(cachePath);
await expectFileNotToExist(staleCachePath);
}