Skip to content

Commit e9ed6a1

Browse files
committed
fix issue with annotations not parsing correctly if already valid json
1 parent 8eba7d6 commit e9ed6a1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

core/lib/annotation_exporter.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ var annotations_exporter = function (pl) {
2626

2727
//parse as JSON by removing the old wrapping js syntax. comments and the trailing semi-colon
2828
oldAnnotations = oldAnnotations.replace('var comments = ', '');
29+
if (oldAnnotations.trim().substr(oldAnnotations.length - 1) === ';') {
30+
oldAnnotations = oldAnnotations.trim().slice(0, -1);
31+
}
32+
2933
try {
30-
var oldAnnotationsJSON = JSON5.parse(oldAnnotations.trim().slice(0, -1));
34+
var oldAnnotationsJSON = JSON5.parse(oldAnnotations);
3135
} catch (ex) {
3236
console.log('There was an error parsing JSON for ' + paths.source.annotations + 'annotations.js');
3337
console.log(ex);

0 commit comments

Comments
 (0)