-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Expand file tree
/
Copy pathcache-info.ts
More file actions
78 lines (67 loc) · 2.59 KB
/
cache-info.ts
File metadata and controls
78 lines (67 loc) · 2.59 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import { execAndWaitForOutputToMatch } from '../../../utils/process';
import { updateJsonFile } from '../../../utils/project';
const ENV_NO_COLOR = {
'NO_COLOR': '1',
};
export default async function () {
const originalCIValue = process.env['CI'];
try {
// Should be enabled by default for local builds.
await configureTest('0' /** envCI */);
await execAndWaitForOutputToMatch('ng', ['cache', 'info'], /Effective Status\s*: Enabled/, {
...process.env,
...ENV_NO_COLOR,
});
// Should be disabled by default for CI builds.
await configureTest('1' /** envCI */, { enabled: true });
await execAndWaitForOutputToMatch('ng', ['cache', 'info'], /Effective Status\s*: Disabled/, {
...process.env,
...ENV_NO_COLOR,
});
// Should be enabled by when environment is local and env is not CI.
await configureTest('0' /** envCI */, { environment: 'local' });
await execAndWaitForOutputToMatch('ng', ['cache', 'info'], /Effective Status\s*: Enabled/, {
...process.env,
...ENV_NO_COLOR,
});
// Should be disabled by when environment is local and env is CI.
await configureTest('1' /** envCI */, { environment: 'local' });
await execAndWaitForOutputToMatch('ng', ['cache', 'info'], /Effective Status\s*: Disabled/, {
...process.env,
...ENV_NO_COLOR,
});
// Effective status should be enabled when 'environment' is set to 'all' or 'ci'.
await configureTest('1' /** envCI */, { environment: 'all' });
await execAndWaitForOutputToMatch('ng', ['cache', 'info'], /Effective Status\s*: Enabled/, {
...process.env,
...ENV_NO_COLOR,
});
// Effective status should be enabled when 'environment' is set to 'ci' and run is in ci
await configureTest('1' /** envCI */, { environment: 'ci' });
await execAndWaitForOutputToMatch('ng', ['cache', 'info'], /Effective Status\s*: Enabled/, {
...process.env,
...ENV_NO_COLOR,
});
// Effective status should be disabled when 'enabled' is set to false
await configureTest('1' /** envCI */, { environment: 'all', enabled: false });
await execAndWaitForOutputToMatch('ng', ['cache', 'info'], /Effective Status\s*: Disabled/, {
...process.env,
...ENV_NO_COLOR,
});
} finally {
process.env['CI'] = originalCIValue;
}
}
async function configureTest(
envCI: '1' | '0',
cacheOptions?: {
environment?: 'ci' | 'local' | 'all';
enabled?: boolean;
},
): Promise<void> {
process.env['CI'] = envCI;
await updateJsonFile('angular.json', (config) => {
config.cli ??= {};
config.cli.cache = cacheOptions;
});
}