@@ -40,20 +40,24 @@ export function createMocksList(files) {
4040 const jsonFiles = files . filter ( ( file ) => file . name . substr ( - 5 ) === '.json' ) ;
4141
4242 const mocksList = jsonFiles . map ( ( file ) => {
43- const contents = JSON . parse ( file . contents ) ;
43+ try {
44+ const contents = JSON . parse ( file . contents ) ;
4445
45- // get plot type keywords from mocks
46- const types = contents . data
47- . map ( ( trace ) => trace . type || 'scatter' )
48- . reduce ( ( acc , type , i , arr ) => ( arr . lastIndexOf ( type ) === i ? [ ...acc , type ] : acc ) , [ ] ) ;
46+ // get plot type keywords from mocks
47+ const types = contents . data
48+ . map ( ( trace ) => trace . type || 'scatter' )
49+ . reduce ( ( acc , type , i , arr ) => ( arr . lastIndexOf ( type ) === i ? [ ...acc , type ] : acc ) , [ ] ) ;
4950
50- const filename = file . name . split ( path . sep ) . pop ( ) ;
51+ const filename = file . name . split ( path . sep ) . pop ( ) ;
5152
52- return {
53- name : filename . slice ( 0 , - 5 ) ,
54- file : filename ,
55- keywords : types . join ( ', ' )
56- } ;
53+ return {
54+ name : filename . slice ( 0 , - 5 ) ,
55+ file : filename ,
56+ keywords : types . join ( ', ' )
57+ } ;
58+ } catch {
59+ console . log ( `Couldn't parse ${ file . name } as JSON. Excluding from mocks list.` ) ;
60+ }
5761 } ) ;
5862
5963 return mocksList ;
0 commit comments