Skip to content

Commit 8d8ddfc

Browse files
authored
fix(@angular/cli): make flag values case insensitive (#5355)
Fixes #5344
1 parent c8e5359 commit 8d8ddfc

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

packages/@angular/cli/blueprints/component/index.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,27 @@ const getFiles = Blueprint.prototype.files;
1212
const stringUtils = require('ember-cli-string-utils');
1313
const astUtils = require('../../utilities/ast-utils');
1414

15+
const viewEncapsulationMap: any = {
16+
'emulated': 'Emulated',
17+
'native': 'Native',
18+
'none': 'None'
19+
};
20+
21+
const changeDetectionMap: any = {
22+
'default': 'Default',
23+
'onpush': 'OnPush'
24+
};
25+
26+
function correctCase(options: any) {
27+
if (options.viewEncapsulation) {
28+
options.viewEncapsulation = viewEncapsulationMap[options.viewEncapsulation.toLowerCase()];
29+
}
30+
31+
if (options.changeDetection) {
32+
options.changeDetection = changeDetectionMap[options.changeDetection.toLowerCase()];
33+
}
34+
}
35+
1536
export default Blueprint.extend({
1637
description: '',
1738

@@ -146,6 +167,8 @@ export default Blueprint.extend({
146167
options.changeDetection = options.changeDetection !== undefined ?
147168
options.changeDetection : CliConfig.getValue('defaults.component.changeDetection');
148169

170+
correctCase(options);
171+
149172
return {
150173
dynamicPath: this.dynamicPath.dir.replace(this.dynamicPath.appRoot, ''),
151174
flat: options.flat,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {join} from 'path';
2+
import {ng} from '../../../utils/process';
3+
import {expectFileToMatch} from '../../../utils/fs';
4+
5+
6+
export default function() {
7+
const compDir = join('src', 'app', 'test');
8+
9+
return Promise.resolve()
10+
.then(() => ng('generate', 'component', 'test', '-cd', 'onpush', '-ve', 'emulated'))
11+
.then(() => expectFileToMatch(join(compDir, 'test.component.ts'),
12+
/changeDetection: ChangeDetectionStrategy.OnPush/))
13+
.then(() => expectFileToMatch(join(compDir, 'test.component.ts'),
14+
/encapsulation: ViewEncapsulation.Emulated/));
15+
}

0 commit comments

Comments
 (0)