Skip to content

Commit d046a1d

Browse files
Fixed duplicate logs
1 parent dcdc88c commit d046a1d

File tree

1 file changed

+8
-5
lines changed
  • packages/contentstack-bulk-publish/src/consumer

1 file changed

+8
-5
lines changed

packages/contentstack-bulk-publish/src/consumer/publish.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,19 @@ function removePublishDetails(elements) {
3535
function displayEntriesDetails(sanitizedData, action, mapping = []) {
3636
if (action === 'bulk_publish') {
3737
sanitizedData.forEach((entry) => {
38-
entry?.publish_details.forEach((pd) => {
39-
if (Object.keys(mapping).includes(pd.environment)) {
38+
if (Array.isArray(entry?.publish_details) && entry.publish_details.length > 0) {
39+
const matchingPublishDetails = entry.publish_details.filter((pd) =>
40+
Object.keys(mapping).includes(pd.environment)
41+
);
42+
if (matchingPublishDetails.length > 0) {
43+
const pd = matchingPublishDetails[0];
4044
console.log(
4145
chalk.green(
4246
`Entry UID: '${entry.uid}', Content Type: '${entry.content_type}', Locale: '${entry.locale}', Version: '${pd.version}', Environment: '${pd.environment}'`,
4347
),
44-
)
48+
);
4549
}
46-
});
47-
if(!Array.isArray(entry.publish_details)){
50+
} else if (!Array.isArray(entry.publish_details)) {
4851
console.log(chalk.green(`Entry UID: '${entry.uid}', Content Type: '${entry.content_type}', Locale: '${entry.locale}'`));
4952
}
5053
});

0 commit comments

Comments
 (0)