Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/labels.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = [
{name: 'in progress', color: 'cccccc'},
{name: 'open', color: 'cccccc'}
];
36 changes: 26 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const GitHubApi = require("github");
const Promise = require('bluebird');
const inquirer = require('inquirer');
const fs = require('fs');
const predefinedLabels = require('./config/labels');

const github = new GitHubApi({
debug: false,
Expand Down Expand Up @@ -43,10 +44,10 @@ function createLabel(repository, owner, name, color) {
}

function getIssues(repository, owner) {
return github.issues.getForRepo({
owner: owner,
repo: repository.name
}).each(issue => issue.repo = repository);
return github.issues.getForRepo({
owner: owner,
repo: repository.name
}).each(issue => issue.repo = repository);
}

function getLabels(repository, owner) {
Expand All @@ -57,12 +58,12 @@ function getLabels(repository, owner) {
}

function addLabels(repository, issue, owner, labels) {
github.issues.addLabels({
owner: owner,
repo: repository.name,
number: issue.number,
body: labels
});
github.issues.addLabels({
owner: owner,
repo: repository.name,
number: issue.number,
body: labels
});
}

function loginBasic() {
Expand Down Expand Up @@ -184,6 +185,21 @@ Promise.coroutine(function*() {
if (selectedRepositories.length == 0) {
return;
}
}

const {addPredefinedLabels} = yield inquirer.prompt([
{
type: 'confirm',
name: 'addPredefinedLabels',
message: 'Do you want to add your predefined labels to the selected Repositories?'
}
]);

if (addPredefinedLabels) {
yield Promise.resolve(predefinedLabels)
.each(label => selectedRepositories.map(repo => createLabel(repo, owner, label.name, label.color)))
return
}

const issues = yield Promise.all(selectedRepositories.map(repo => getIssues(repo, owner)))
.reduce((all, current) => all.concat(current));
Expand Down