Skip to content

Commit e0edcc0

Browse files
committed
chore: code review
1 parent f909af7 commit e0edcc0

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/generators/legacy-json-all/index.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ export default {
5353
input.forEach(section => {
5454
// Copy the relevant properties from each section into our output
5555
propertiesToCopy.forEach(property => {
56-
if (Array.isArray(section[property])) {
57-
let toPush = section[property];
56+
const items = section[property];
5857

59-
if (section.source) {
60-
toPush = toPush.map(item => ({ ...item, source: section.source }));
61-
}
58+
if (Array.isArray(items)) {
59+
const enrichedItems = section.source
60+
? items.map(item => ({ ...item, source: section.source }))
61+
: items;
6262

63-
generatedValue[property].push(...toPush);
63+
generatedValue[property].push(...enrichedItems);
6464
}
6565
});
6666
});

src/generators/legacy-json/utils/buildSection.mjs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,8 @@ export const createSectionBuilder = () => {
6464
}
6565

6666
// Check if there are any non-empty fields in the meta object
67-
const atLeastOneNonEmptyField = Object.values(meta).some(
68-
value => value.length > 0
69-
);
67+
const atLeastOneNonEmptyField =
68+
changes?.length || Object.keys(meta).length > 1;
7069

7170
// Return undefined if the meta object is completely empty
7271
return atLeastOneNonEmptyField ? meta : undefined;

0 commit comments

Comments
 (0)