@@ -154,26 +154,42 @@ var pattern_assembler = function () {
154154 //look for a json file for this template
155155 try {
156156 var jsonFilename = path . resolve ( patternsPath , currentPattern . subdir , currentPattern . fileName + ".json" ) ;
157- currentPattern . jsonFileData = fs . readJSONSync ( jsonFilename ) ;
158- if ( patternlab . config . debug ) {
159- console . log ( 'processPatternIterative: found pattern-specific data.json for ' + currentPattern . patternPartial ) ;
157+ try {
158+ var jsonFilenameStats = fs . statSync ( jsonFilename ) ;
159+ } catch ( err ) {
160+ //not a file
161+ }
162+ if ( jsonFilenameStats && jsonFilenameStats . isFile ( ) ) {
163+ currentPattern . jsonFileData = fs . readJSONSync ( jsonFilename ) ;
164+ if ( patternlab . config . debug ) {
165+ console . log ( 'processPatternIterative: found pattern-specific data.json for ' + currentPattern . patternPartial ) ;
166+ }
160167 }
161168 }
162- catch ( e ) {
163- // do nothing
169+ catch ( err ) {
170+ console . log ( 'There was an error parsing sibling JSON for ' + currentPattern . relPath ) ;
171+ console . log ( err ) ;
164172 }
165173
166174 //look for a listitems.json file for this template
167175 try {
168176 var listJsonFileName = path . resolve ( patternsPath , currentPattern . subdir , currentPattern . fileName + ".listitems.json" ) ;
169- currentPattern . listitems = fs . readJSONSync ( listJsonFileName ) ;
170- buildListItems ( currentPattern ) ;
171- if ( patternlab . config . debug ) {
172- console . log ( 'found pattern-specific listitems.json for ' + currentPattern . patternPartial ) ;
177+ try {
178+ var listJsonFileStats = fs . statSync ( listJsonFileName ) ;
179+ } catch ( err ) {
180+ //not a file
181+ }
182+ if ( listJsonFileStats && listJsonFileStats . isFile ( ) ) {
183+ currentPattern . listitems = fs . readJSONSync ( listJsonFileName ) ;
184+ buildListItems ( currentPattern ) ;
185+ if ( patternlab . config . debug ) {
186+ console . log ( 'found pattern-specific listitems.json for ' + currentPattern . patternPartial ) ;
187+ }
173188 }
174189 }
175- catch ( e ) {
176- // do nothing
190+ catch ( err ) {
191+ console . log ( 'There was an error parsing sibling listitem JSON for ' + currentPattern . relPath ) ;
192+ console . log ( err ) ;
177193 }
178194
179195 //look for a markdown file for this template
0 commit comments