Skip to content

Commit

Permalink
Revise for label json
Browse files Browse the repository at this point in the history
  • Loading branch information
t-will-gillis committed Jan 31, 2025
1 parent 1126960 commit 644ea80
Showing 1 changed file with 20 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
// Import modules
const retrieveLabelDirectory = require('../../utils/retrieve-label-directory');

// Global variables
var github
var context

// Label constants use labelKeys to retrieve current labelNames from directory
const RELEVANT_ROLES = [
roleFrontEnd,
roleBackEndDevOps,
roleDesign,
roleUserResearch
] = [
"roleFrontEnd",
"roleBackEndDevOps",
"roleDesign",
"roleUserResearch",
].map(retrieveLabelDirectory);

/**
* @description - entry point of the whole javascript file, finds out whether we need to post the comment or not and returns in the boolean variable shouldpost.
* @param {Object} github - github object
Expand All @@ -17,7 +33,7 @@ function main({g, c}){
var existingLabels = obtainLabels()

//With the existing labels we see if we are to post the comment or not(based on whether there exists a relevant role tag or not) and return it as a boolean
var shouldPost = postComment(existingLabels)
var shouldPost = checkIfLabelsIncludeRoles(existingLabels)

return({shouldPost,issueNum})
}
Expand All @@ -41,29 +57,9 @@ function obtainLabels(){
* @returns - A boolean which tells whether we are supposed to post a preliminary update based on the given issue checks
*/

function postComment(existingLabels){
//issue states that we are to post the comment if--> there is a role: back end/devOps tag...(continued on next comment)
if(existingLabels.includes("role: back end/devOps")){
return true
}

// or if there is a role: front end tag
else if(existingLabels.includes("role: front end")){
return true
}

//or if there is a role: design tag
else if(existingLabels.includes("role: design")){
return true
}

//or if there is a role: user research
else if(existingLabels.includes("role: user research")){
return true
}

//otherwise we return a false
return false
function checkIfLabelsIncludeRoles(existingLabels){
// Compare whether a RELEVANT_ROLE is included in the existingLabels
return RELEVANT_ROLES.some(label => existingLabels.includes(label));
}

module.exports = main

0 comments on commit 644ea80

Please sign in to comment.