5
5
* Use of this source code is governed by an MIT-style license that can be
6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
- import { json } from '@angular-devkit/core' ;
8
+ import { json , logging } from '@angular-devkit/core' ;
9
9
import { ExportStringRef } from '@angular-devkit/schematics/tools' ;
10
10
import { readFileSync } from 'fs' ;
11
11
import { dirname , resolve } from 'path' ;
@@ -36,6 +36,7 @@ export async function parseJsonSchemaToSubCommandDescription(
36
36
jsonPath : string ,
37
37
registry : json . schema . SchemaRegistry ,
38
38
schema : json . JsonObject ,
39
+ logger : logging . Logger ,
39
40
) : Promise < SubCommandDescription > {
40
41
const options = await parseJsonSchemaToOptions ( registry , schema ) ;
41
42
@@ -61,12 +62,20 @@ export async function parseJsonSchemaToSubCommandDescription(
61
62
let longDescription = '' ;
62
63
if ( typeof schema . $longDescription == 'string' && schema . $longDescription ) {
63
64
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
+ }
65
70
}
66
71
let usageNotes = '' ;
67
72
if ( typeof schema . $usageNotes == 'string' && schema . $usageNotes ) {
68
73
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
+ }
70
79
}
71
80
72
81
const description = '' + ( schema . description === undefined ? '' : schema . description ) ;
@@ -86,8 +95,10 @@ export async function parseJsonSchemaToCommandDescription(
86
95
jsonPath : string ,
87
96
registry : json . schema . SchemaRegistry ,
88
97
schema : json . JsonObject ,
98
+ logger : logging . Logger ,
89
99
) : Promise < CommandDescription > {
90
- const subcommand = await parseJsonSchemaToSubCommandDescription ( name , jsonPath , registry , schema ) ;
100
+ const subcommand =
101
+ await parseJsonSchemaToSubCommandDescription ( name , jsonPath , registry , schema , logger ) ;
91
102
92
103
// Before doing any work, let's validate the implementation.
93
104
if ( typeof schema . $impl != 'string' ) {
0 commit comments