2021-01-19 11:54:16 +01:00
|
|
|
import {Issue} from '../classes/issue';
|
2021-02-13 12:09:37 +01:00
|
|
|
import {ILabel} from '../interfaces/label';
|
2021-07-12 13:56:58 -04:00
|
|
|
import {cleanLabel} from './clean-label';
|
2021-01-15 12:51:24 +01:00
|
|
|
|
2020-11-20 12:48:33 +01:00
|
|
|
/**
|
|
|
|
|
* @description
|
2021-01-19 11:54:16 +01:00
|
|
|
* Check if the given label is listed as a label of the given issue
|
2020-11-20 12:48:33 +01:00
|
|
|
*
|
|
|
|
|
* @param {Readonly<Issue>} issue A GitHub issue containing some labels
|
|
|
|
|
* @param {Readonly<string>} label The label to check the presence with
|
|
|
|
|
*
|
2021-01-19 11:54:16 +01:00
|
|
|
* @return {boolean} Return true when the given label is also in the given issue labels
|
2020-11-20 12:48:33 +01:00
|
|
|
*/
|
|
|
|
|
export function isLabeled(
|
|
|
|
|
issue: Readonly<Issue>,
|
|
|
|
|
label: Readonly<string>
|
|
|
|
|
): boolean {
|
2021-02-13 12:09:37 +01:00
|
|
|
return !!issue.labels.find((issueLabel: Readonly<ILabel>): boolean => {
|
2020-11-20 12:48:33 +01:00
|
|
|
return cleanLabel(label) === cleanLabel(issueLabel.name);
|
|
|
|
|
});
|
|
|
|
|
}
|