fix(@angular/cli): fix support for default values in options

This commit is contained in:
Hans 2018-09-14 11:24:20 -07:00
parent b5fc50fa1c
commit d10c9e3104
2 changed files with 8 additions and 11 deletions

View File

@ -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);
}
}

View File

@ -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)) {