Files
stale/src/functions/is-labeled.ts
Luke Tomlinson a78d0b721e Make label comparison case insensitive (#517)
* Make label comparison case insensitive

* PR Feedback
2021-07-12 13:56:58 -04:00

22 lines
693 B
TypeScript

import {Issue} from '../classes/issue';
import {ILabel} from '../interfaces/label';
import {cleanLabel} from './clean-label';
/**
* @description
* Check if the given label is listed as a label of the given 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 given issue labels
*/
export function isLabeled(
issue: Readonly<Issue>,
label: Readonly<string>
): boolean {
return !!issue.labels.find((issueLabel: Readonly<ILabel>): boolean => {
return cleanLabel(label) === cleanLabel(issueLabel.name);
});
}