Skip to content

Commit fbcefe5

Browse files
Broccohansl
authored andcommitted
fix(@angular/cli): Correct reading of camel-cased defaults
fixes #10371 based upon PR #10570
1 parent 062faaa commit fbcefe5

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

packages/@angular/cli/models/schematic-command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ export abstract class SchematicCommand extends Command {
334334

335335
private _cleanDefaults<T, K extends keyof T>(defaults: T, undefinedOptions: string[]): T {
336336
(Object.keys(defaults) as K[])
337-
.filter(key => !undefinedOptions.includes(key))
337+
.filter(key => !undefinedOptions.map(strings.camelize).includes(key))
338338
.forEach(key => {
339339
delete defaults[key];
340340
});

tests/e2e/tests/commands/config/config-global.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {expectToFail} from '../../../utils/utils';
33
import { expectFileToExist } from '../../../utils/fs';
44
import * as path from 'path';
55
import { homedir } from 'os';
6+
import { deleteFile } from '../../../utils/fs';
67

78

89
export default function() {
@@ -27,5 +28,6 @@ export default function() {
2728
})
2829
.then(() => expectToFail(() => ng('config', '--global', 'cli.warnings.notreal', 'true')))
2930
.then(() => ng('config', '--global', 'cli.warnings.versionMismatch', 'false'))
30-
.then(() => expectFileToExist(path.join(homedir(), '.angular-config.json')));
31+
.then(() => expectFileToExist(path.join(homedir(), '.angular-config.json')))
32+
.then(() => deleteFile(path.join(homedir(), '.angular-config.json')));
3133
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import {join} from 'path';
2+
import {ng} from '../../../utils/process';
3+
import {expectFileToExist} from '../../../utils/fs';
4+
import {updateJsonFile} from '../../../utils/project';
5+
import { expectToFail } from '../../../utils/utils';
6+
7+
8+
// tslint:disable:max-line-length
9+
export default function() {
10+
const componentDir = join('src', 'app', 'test-component');
11+
return Promise.resolve()
12+
.then(() => updateJsonFile('angular.json', configJson => {
13+
configJson.projects['test-project'].schematics = {
14+
'@schematics/angular:component': { inlineTemplate: true }
15+
};
16+
}))
17+
.then(() => ng('generate', 'component', 'test-component'))
18+
.then(() => expectFileToExist(componentDir))
19+
.then(() => expectFileToExist(join(componentDir, 'test-component.component.ts')))
20+
.then(() => expectFileToExist(join(componentDir, 'test-component.component.spec.ts')))
21+
.then(() => expectToFail(() => expectFileToExist(join(componentDir, 'test-component.component.html'))))
22+
.then(() => expectFileToExist(join(componentDir, 'test-component.component.css')))
23+
24+
// Try to run the unit tests.
25+
.then(() => ng('test', '--watch=false'));
26+
}

0 commit comments

Comments
 (0)