Skip to content

Commit bf15b20

Browse files
alan-agius4dgp1130
authored andcommitted
fix(@angular/cli): remove cache path from global valid paths
`cli.cache` cannot be configured globally and therefore it should not be listed as part of the `validCliPaths` Map.
1 parent 108a0b6 commit bf15b20

File tree

1 file changed

+17
-18
lines changed
  • packages/angular/cli/src/commands/config

1 file changed

+17
-18
lines changed

packages/angular/cli/src/commands/config/cli.ts

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -97,28 +97,21 @@ export class ConfigCommandModule
9797
throw new CommandModuleError('Invalid Path.');
9898
}
9999

100-
const validCliPaths = new Map<
101-
string,
102-
((arg: string | number | boolean | undefined) => string) | undefined
103-
>([
104-
['cli.warnings.versionMismatch', undefined],
105-
['cli.defaultCollection', undefined],
106-
['cli.schematicCollections', undefined],
107-
['cli.packageManager', undefined],
108-
['cli.analytics', undefined],
109-
110-
['cli.analyticsSharing.tracking', undefined],
111-
['cli.analyticsSharing.uuid', (v) => (v === '' ? uuidV4() : `${v}`)],
112-
113-
['cli.cache.enabled', undefined],
114-
['cli.cache.environment', undefined],
115-
['cli.cache.path', undefined],
100+
const validGlobalCliPaths = new Set<string>([
101+
'cli.warnings.versionMismatch',
102+
'cli.defaultCollection',
103+
'cli.schematicCollections',
104+
'cli.packageManager',
105+
106+
'cli.analytics',
107+
'cli.analyticsSharing.tracking',
108+
'cli.analyticsSharing.uuid',
116109
]);
117110

118111
if (
119112
options.global &&
120113
!options.jsonPath.startsWith('schematics.') &&
121-
!validCliPaths.has(options.jsonPath)
114+
!validGlobalCliPaths.has(options.jsonPath)
122115
) {
123116
throw new CommandModuleError('Invalid Path.');
124117
}
@@ -130,7 +123,13 @@ export class ConfigCommandModule
130123
throw new CommandModuleError('Confguration file cannot be found.');
131124
}
132125

133-
const value = validCliPaths.get(options.jsonPath)?.(options.value) ?? options.value;
126+
const normalizeUUIDValue = (v: string | undefined) => (v === '' ? uuidV4() : `${v}`);
127+
128+
const value =
129+
options.jsonPath === 'cli.analyticsSharing.uuid'
130+
? normalizeUUIDValue(options.value)
131+
: options.value;
132+
134133
const modified = config.modify(parseJsonPath(options.jsonPath), normalizeValue(value));
135134

136135
if (!modified) {

0 commit comments

Comments
 (0)