Skip to content

Commit

Permalink
fix(@angular/cli): fix support for default values in options
Browse files Browse the repository at this point in the history
  • Loading branch information
hansl committed Sep 15, 2018
1 parent b5fc50f commit d10c9e3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
17 changes: 7 additions & 10 deletions packages/angular/cli/utilities/json-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,26 +151,23 @@ export async function parseJsonSchemaToOptions(
}

let defaultValue: string | number | boolean | undefined = undefined;
if (schema.default !== undefined) {
if (current.default !== undefined) {
switch (types[0]) {
case 'string':
if (typeof schema.default == 'string') {
defaultValue = schema.default;
if (typeof current.default == 'string') {
defaultValue = current.default;
}
break;
case 'number':
if (typeof schema.default == 'number') {
defaultValue = schema.default;
if (typeof current.default == 'number') {
defaultValue = current.default;
}
break;
case 'boolean':
if (typeof schema.default == 'boolean') {
defaultValue = schema.default;
if (typeof current.default == 'boolean') {
defaultValue = current.default;
}
break;

default:
console.log(types[0], schema);
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/legacy-cli/e2e/tests/generate/help-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default function() {
.then(() => ng('generate', 'fake', '--help'))
// verify same output
.then(({stdout}) => {
if (!/ng generate fake-schematics:fake <a> <b> \[options\]/.test(stdout)) {
if (!/ng generate fake <a> <b> \[options\]/.test(stdout)) {
throw new Error('Help signature is wrong (2).');
}
if (!/opt-a[\s\S]*opt-b[\s\S]*opt-c/.test(stdout)) {
Expand Down

0 comments on commit d10c9e3

Please sign in to comment.