mirror of
https://github.com/actions/stale.git
synced 2025-12-20 06:42:15 +00:00
fix(label): allow to use spaces inside the labels (#199)
* chore(git): ignore .idea folder to avoid adding WebStorm files * test(jest): find all spec files as well * refactor(labels): create a dedicated function to parse the labels at first I thought that the parseCommaSeparatedString method was causing the issue so I move it to a dedicated file to test it since it was private also because I think that this repo could have more clean code and code splitting anyway this was not the root of the #98 issue :/ * fix(label): allow to use spaces inside the labels * docs(isLabeled): add JSDoc * chore(npm): add lint:fix script
This commit is contained in:
committed by
GitHub
parent
9b82e8c1ef
commit
324009e5d0
24
src/functions/is-labeled.ts
Normal file
24
src/functions/is-labeled.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import deburr from 'lodash.deburr';
|
||||
import {Issue, Label} from '../IssueProcessor';
|
||||
|
||||
/**
|
||||
* @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);
|
||||
});
|
||||
}
|
||||
|
||||
function cleanLabel(label: Readonly<string>): string {
|
||||
return deburr(label.toLowerCase());
|
||||
}
|
||||
Reference in New Issue
Block a user