Skip to content

Commit 5b64a57

Browse files
committed
updated the utils
1 parent de87f3c commit 5b64a57

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed

src/index.js

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,23 @@ function createTaskBadge(url) {
200200
* @returns {string} - parsed message.
201201
*/
202202
function pullRequestParser(content) {
203-
const taskTitle = Utils.trimString(escapeChars(content.title), TRIM_PR_NAME_LENGHT);
203+
const {
204+
title,
205+
latestOpinionatedReviews,
206+
latestReviews,
207+
reviewRequests,
208+
author,
209+
url,
210+
} = content;
211+
212+
const taskTitle = Utils.trimString(escapeChars(title), TRIM_PR_NAME_LENGHT);
204213
const reviewState = createReviewStatus(
205-
content.latestOpinionatedReviews,
206-
content.latestReviews,
207-
content.reviewRequests
214+
latestOpinionatedReviews,
215+
latestReviews,
216+
reviewRequests
208217
);
209218

210-
const parsedTask = `${createTaskBadge(content.url)}: <a href="${content.url
211-
}">${taskTitle}</a> ${reviewState} @${content.author.login}`;
219+
const parsedTask = `${createTaskBadge(url)}: <a href="${url}">${taskTitle}</a> ${reviewState} @${author.login}`;
212220

213221
/**
214222
* @todo discuss if it is necessary to duplicate links to pr
@@ -235,14 +243,18 @@ function pullRequestParser(content) {
235243
* @returns {string} - parsed message.
236244
*/
237245
function issuesParser(content) {
238-
const taskTitle = Utils.trimString(escapeChars(content.title), TRIM_PR_NAME_LENGHT);
239-
240-
let parsedTask = `${createTaskBadge(content.url)}: <a href="${content.url
241-
}">${escapeChars(taskTitle)}</a>`;
242-
243-
if (Utils.isPropertyExist(content, 'assignees', 'nodes')) {
244-
content.assignees.nodes.forEach((node) => {
245-
parsedTask += `@${node.login} `;
246+
const {
247+
title,
248+
assignees,
249+
url,
250+
} = content;
251+
const taskTitle = Utils.trimString(escapeChars(title), TRIM_PR_NAME_LENGHT);
252+
253+
let parsedTask = `${createTaskBadge(url)}: <a href="${url}">${escapeChars(taskTitle)}</a>`;
254+
255+
if (Utils.isPropertyExist(assignees, 'nodes')) {
256+
assignees.nodes.forEach(({ login }) => {
257+
parsedTask += `@${login} `;
246258
});
247259
}
248260

src/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Utils {
2323
* @returns {boolean}
2424
*/
2525
static isPropertyExist(obj, property, ...rest) {
26-
if (obj === undefined) {
26+
if (obj === undefined || obj === null) {
2727
return false;
2828
}
2929
if (rest.length == 0 && Object.prototype.hasOwnProperty.call(obj, property)) {

0 commit comments

Comments
 (0)