Skip to content

Commit 2d2c0d5

Browse files
committed
addressing if annotations are missing
1 parent e0cdee5 commit 2d2c0d5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/PatternLab/Annotations.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ public static function gather() {
5555
if (!is_dir($annotationsDir)) {
5656
Console::writeWarning("<path>".Console::getHumanReadablePath($annotationsDir)."</path><warning> doesn't exist so you won't have annotations...");
5757
mkdir($annotationsDir);
58+
} else {
59+
60+
5861
}
5962

6063
// find the markdown-based annotations
@@ -90,6 +93,7 @@ public static function gather() {
9093
}
9194

9295
// read in the old style annotations.js, modify the data and generate JSON array to merge
96+
$data = array();
9397
$oldStyleAnnotationsPath = $annotationsDir.DIRECTORY_SEPARATOR."annotations.js";
9498
if (file_exists($oldStyleAnnotationsPath)) {
9599
$text = trim(file_get_contents($oldStyleAnnotationsPath));
@@ -103,8 +107,10 @@ public static function gather() {
103107
}
104108
}
105109

106-
// merge in any data from the old file
107-
self::$store["comments"] = array_merge(self::$store["comments"],$data["comments"]);
110+
// merge in any data from the old file if the json decode was successful
111+
if (is_array($data) && isset($data["comments"])) {
112+
self::$store["comments"] = array_merge(self::$store["comments"],$data["comments"]);
113+
}
108114

109115
$dispatcherInstance->dispatch("annotations.gatherEnd");
110116

0 commit comments

Comments
 (0)