refactor: extract exclude-labels array to outer scope (#75)

This commit is contained in:
meteorlxy
2021-08-09 23:41:33 +08:00
committed by GitHub
parent 86102bcaef
commit db8ab69114

View File

@@ -60,6 +60,7 @@ async function doQueryIssues(owner, repo, labels, state, creator) {
let issues = [];
let issueNumbers = [];
if (res.length) {
const excludeLabelsArr = dealStringToArr(excludeLabels);
res.forEach(iss => {
const a = bodyIncludes ? iss.body.includes(bodyIncludes) : true;
const b = titleIncludes ? iss.title.includes(titleIncludes) : true;
@@ -69,10 +70,9 @@ async function doQueryIssues(owner, repo, labels, state, creator) {
* You can identify pull requests by the pull_request key.
*/
if (a && b && iss.pull_request === undefined) {
if (excludeLabels) {
const labels = dealStringToArr(excludeLabels);
if (excludeLabelsArr.length) {
for (let i = 0; i < iss.labels.length; i += 1) {
if (labels.includes(iss.labels[i].name)) return;
if (excludeLabelsArr.includes(iss.labels[i].name)) return;
}
}