Update index.js
This commit is contained in:
parent
3ef25d9bb0
commit
345b170e18
1 changed files with 35 additions and 29 deletions
64
index.js
64
index.js
|
@ -18,42 +18,48 @@ async function run() {
|
||||||
|
|
||||||
console.log({ newLabels, labels });
|
console.log({ newLabels, labels });
|
||||||
|
|
||||||
newLabels.forEach(async label => {
|
let idxs = await Promise.all(
|
||||||
let { name, color, description } = label;
|
newLabels.forEach(async label => {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
let { name, color, description } = label;
|
||||||
|
|
||||||
let idx = -1;
|
let idx = -1;
|
||||||
|
|
||||||
if (labels.length > 0) {
|
if (labels.length > 0) {
|
||||||
idx = labels.findIndex(issue => issue.name === name);
|
idx = labels.findIndex(issue => issue.name === name);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log({ idx });
|
console.log({ idx });
|
||||||
|
|
||||||
if (idx !== -1) {
|
if (idx !== -1) {
|
||||||
let params = tools.context.repo({
|
let params = tools.context.repo({
|
||||||
current_name: name,
|
current_name: name,
|
||||||
color,
|
color,
|
||||||
description,
|
description,
|
||||||
headers: { accept: "application/vnd.github.symmetra-preview+json" }
|
headers: { accept: "application/vnd.github.symmetra-preview+json" }
|
||||||
|
});
|
||||||
|
console.log("UPDATE");
|
||||||
|
await octokit.issues.updateLabel(params);
|
||||||
|
resolve(idx);
|
||||||
|
} else {
|
||||||
|
let params = tools.context.repo({
|
||||||
|
name,
|
||||||
|
color,
|
||||||
|
description,
|
||||||
|
headers: { accept: "application/vnd.github.symmetra-preview+json" }
|
||||||
|
});
|
||||||
|
console.log("CREATE");
|
||||||
|
await octokit.issues.createLabel(params);
|
||||||
|
resolve(-1);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
console.log("UPDATE");
|
})
|
||||||
await octokit.issues.updateLabel(params);
|
);
|
||||||
labels.splice(idx, 1);
|
|
||||||
console.log("AFTER SPLICE", labels);
|
labels = labels.filter((_, idx) => {
|
||||||
} else {
|
return !idxs.includes(idx);
|
||||||
let params = tools.context.repo({
|
|
||||||
name,
|
|
||||||
color,
|
|
||||||
description,
|
|
||||||
headers: { accept: "application/vnd.github.symmetra-preview+json" }
|
|
||||||
});
|
|
||||||
console.log("CREATE");
|
|
||||||
await octokit.issues.createLabel(params);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(labels);
|
|
||||||
|
|
||||||
// Delete labels that exist on GitHub that aren't in labels.json
|
// Delete labels that exist on GitHub that aren't in labels.json
|
||||||
labels.forEach(async label => {
|
labels.forEach(async label => {
|
||||||
let { name } = label;
|
let { name } = label;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue