imdone-core 2.0.15 → 2.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/project.js +44 -18
- package/package.json +1 -1
package/lib/project.js
CHANGED
|
@@ -576,26 +576,52 @@ export class WorkerProject extends Project {
|
|
|
576
576
|
}
|
|
577
577
|
|
|
578
578
|
addMetaToContent(meta, content) {
|
|
579
|
-
if (meta
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
579
|
+
if (!meta) return content;
|
|
580
|
+
|
|
581
|
+
// Handle both array format and object format
|
|
582
|
+
let metaArray = [];
|
|
583
|
+
|
|
584
|
+
if (Array.isArray(meta)) {
|
|
585
|
+
// Current format: [{key, value}, ...]
|
|
586
|
+
metaArray = meta;
|
|
587
|
+
} else if (typeof meta === 'object') {
|
|
588
|
+
// New format: {key1: [values], key2: [values], ...}
|
|
589
|
+
metaArray = [];
|
|
590
|
+
Object.entries(meta).forEach(([key, values]) => {
|
|
591
|
+
if (Array.isArray(values)) {
|
|
592
|
+
values.forEach(value => {
|
|
593
|
+
metaArray.push({ key, value });
|
|
594
|
+
});
|
|
595
|
+
} else {
|
|
596
|
+
// Single value case
|
|
597
|
+
metaArray.push({ key, value: values });
|
|
593
598
|
}
|
|
594
|
-
|
|
595
|
-
metaContent = `${metaContent}${spaceOrNewLine}${metaData}`
|
|
596
|
-
})
|
|
597
|
-
content = Task.addToLastCommentInContent(content, metaContent.trim(), this.config.isMetaNewLine())
|
|
599
|
+
});
|
|
598
600
|
}
|
|
601
|
+
|
|
602
|
+
if (metaArray.length === 0) return content;
|
|
603
|
+
|
|
604
|
+
let metaContent = '';
|
|
605
|
+
metaArray.forEach(({ key, value }) => {
|
|
606
|
+
if (!/^['"]/.test(value) && /\s/.test(value)) value = `"${value}"`;
|
|
607
|
+
const metaData = `${key}${this.config.getMetaSep()}${value}`;
|
|
608
|
+
if (content.includes(metaData)) return;
|
|
609
|
+
|
|
610
|
+
const existingMetadata = Task.parseMetaData(this.config, content)[key];
|
|
611
|
+
if (existingMetadata) {
|
|
612
|
+
content = Task.removeMetaData({
|
|
613
|
+
config: this.config,
|
|
614
|
+
content,
|
|
615
|
+
key,
|
|
616
|
+
value: existingMetadata[0],
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
const spaceOrNewLine = this.config.isMetaNewLine() ? '\n' : ' ';
|
|
621
|
+
metaContent = `${metaContent}${spaceOrNewLine}${metaData}`;
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
content = Task.addToLastCommentInContent(content, metaContent.trim(), this.config.isMetaNewLine())
|
|
599
625
|
return content
|
|
600
626
|
}
|
|
601
627
|
|