Skip to content

Commit a058a03

Browse files
committed
chore(data): defensively define data.link
1 parent b7936f2 commit a058a03

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

core/lib/pattern_assembler.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ const pattern_assembler = function () {
8585
function addPattern(pattern, patternlab) {
8686

8787
//add the link to the global object
88+
if (!patternlab.data.link) {
89+
patternlab.data.link = {};
90+
}
8891
patternlab.data.link[pattern.patternPartial] = '/patterns/' + pattern.patternLink;
8992

9093
//only push to array if the array doesn't contain this pattern

core/lib/patternlab.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ module.exports = class PatternLab {
5353
// INITIALIZE EMPTY GLOBAL DATA STRUCTURES
5454
//
5555
this.data = {};
56-
this.data.link = {};
5756
this.patterns = [];
5857
this.subtypePatterns = {};
5958
this.partials = {};
@@ -147,6 +146,7 @@ module.exports = class PatternLab {
147146
// data.json
148147
try {
149148
this.data = this.buildPatternData(paths.source.data, fs); // eslint-disable-line no-use-before-define
149+
this.data.link = {};
150150
} catch (ex) {
151151
logger.error('missing or malformed' + paths.source.data + 'data.json Pattern Lab may not work without this file.');
152152
this.data = {};

0 commit comments

Comments
 (0)