File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -65,8 +65,26 @@ export async function runVoices(
6565 }
6666
6767 const context = readFile ( contextPath ) ;
68- const i18nRaw = fs . readFileSync ( i18nPath , "utf-8" ) ;
69- const i18n = JSON . parse ( i18nRaw ) ;
68+ if ( context . startsWith ( "[Error:" ) ) {
69+ fail ( `Cannot read context file: ${ contextPath } ` ) ;
70+ return ;
71+ }
72+
73+ let i18nRaw : string ;
74+ try {
75+ i18nRaw = fs . readFileSync ( i18nPath , "utf-8" ) ;
76+ } catch ( e ) {
77+ fail ( `Cannot read i18n file: ${ i18nPath } \n${ e } ` ) ;
78+ return ;
79+ }
80+
81+ let i18n : Record < string , unknown > ;
82+ try {
83+ i18n = JSON . parse ( i18nRaw ) ;
84+ } catch ( e ) {
85+ fail ( `Malformed JSON in ${ i18nPath } : ${ e } ` ) ;
86+ return ;
87+ }
7088 const voices : Record < string , string > = { ...( i18n . provider ?. voices ?? { } ) } ;
7189
7290 phase ( "Brand Voices" , targetLocales . join ( " " ) ) ;
You can’t perform that action at this time.
0 commit comments