55 * Use of this source code is governed by an MIT-style license that can be
66 * found in the LICENSE file at https://angular.io/license
77 */
8- import { json } from '@angular-devkit/core' ;
8+ import { json , logging } from '@angular-devkit/core' ;
99import { ExportStringRef } from '@angular-devkit/schematics/tools' ;
1010import { readFileSync } from 'fs' ;
1111import { dirname , resolve } from 'path' ;
@@ -36,6 +36,7 @@ export async function parseJsonSchemaToSubCommandDescription(
3636 jsonPath : string ,
3737 registry : json . schema . SchemaRegistry ,
3838 schema : json . JsonObject ,
39+ logger : logging . Logger ,
3940) : Promise < SubCommandDescription > {
4041 const options = await parseJsonSchemaToOptions ( registry , schema ) ;
4142
@@ -61,12 +62,20 @@ export async function parseJsonSchemaToSubCommandDescription(
6162 let longDescription = '' ;
6263 if ( typeof schema . $longDescription == 'string' && schema . $longDescription ) {
6364 const ldPath = resolve ( dirname ( jsonPath ) , schema . $longDescription ) ;
64- longDescription = readFileSync ( ldPath , 'utf-8' ) ;
65+ try {
66+ longDescription = readFileSync ( ldPath , 'utf-8' ) ;
67+ } catch ( e ) {
68+ logger . warn ( `File ${ ldPath } was not found while constructing the subcommand ${ name } .` ) ;
69+ }
6570 }
6671 let usageNotes = '' ;
6772 if ( typeof schema . $usageNotes == 'string' && schema . $usageNotes ) {
6873 const unPath = resolve ( dirname ( jsonPath ) , schema . $usageNotes ) ;
69- usageNotes = readFileSync ( unPath , 'utf-8' ) ;
74+ try {
75+ usageNotes = readFileSync ( unPath , 'utf-8' ) ;
76+ } catch ( e ) {
77+ logger . warn ( `File ${ unPath } was not found while constructing the subcommand ${ name } .` ) ;
78+ }
7079 }
7180
7281 const description = '' + ( schema . description === undefined ? '' : schema . description ) ;
@@ -86,8 +95,10 @@ export async function parseJsonSchemaToCommandDescription(
8695 jsonPath : string ,
8796 registry : json . schema . SchemaRegistry ,
8897 schema : json . JsonObject ,
98+ logger : logging . Logger ,
8999) : Promise < CommandDescription > {
90- const subcommand = await parseJsonSchemaToSubCommandDescription ( name , jsonPath , registry , schema ) ;
100+ const subcommand =
101+ await parseJsonSchemaToSubCommandDescription ( name , jsonPath , registry , schema , logger ) ;
91102
92103 // Before doing any work, let's validate the implementation.
93104 if ( typeof schema . $impl != 'string' ) {
0 commit comments