2020-11-20 12:48:33 +01:00
|
|
|
import deburr from 'lodash.deburr';
|
|
|
|
|
import {Issue, Label} from '../IssueProcessor';
|
2021-01-18 02:22:36 +01:00
|
|
|
import {CleanLabel} from '../types/clean-label';
|
2021-01-15 12:51:24 +01:00
|
|
|
|
2020-11-20 12:48:33 +01:00
|
|
|
/**
|
|
|
|
|
* @description
|
|
|
|
|
* Check if the label is listed as a label of the issue
|
|
|
|
|
*
|
|
|
|
|
* @param {Readonly<Issue>} issue A GitHub issue containing some labels
|
|
|
|
|
* @param {Readonly<string>} label The label to check the presence with
|
|
|
|
|
*
|
|
|
|
|
* @return {boolean} Return true when the given label is also in the issue labels
|
|
|
|
|
*/
|
|
|
|
|
export function isLabeled(
|
|
|
|
|
issue: Readonly<Issue>,
|
|
|
|
|
label: Readonly<string>
|
|
|
|
|
): boolean {
|
|
|
|
|
return !!issue.labels.find((issueLabel: Readonly<Label>): boolean => {
|
|
|
|
|
return cleanLabel(label) === cleanLabel(issueLabel.name);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-15 12:51:24 +01:00
|
|
|
function cleanLabel(label: Readonly<string>): CleanLabel {
|
2020-11-20 12:48:33 +01:00
|
|
|
return deburr(label.toLowerCase());
|
|
|
|
|
}
|