@@ -154,26 +154,42 @@ var pattern_assembler = function () {
154
154
//look for a json file for this template
155
155
try {
156
156
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
+ }
160
167
}
161
168
}
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);
164
172
}
165
173
166
174
//look for a listitems.json file for this template
167
175
try {
168
176
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
+ }
173
188
}
174
189
}
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);
177
193
}
178
194
179
195
//look for a markdown file for this template
0 commit comments