Skip to content

Commit

Permalink
refactor: redefine log module job
Browse files Browse the repository at this point in the history
  • Loading branch information
hemal7735 committed Dec 3, 2018
1 parent 658994e commit 739bbfd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
8 changes: 4 additions & 4 deletions bin/good-first-issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ cli
process.exit(0)
}

// Call the log functionality, output the result to the console.
let output = await log(issues, projects[input].name)
let key = cmd.first ? 0 : Math.floor(Math.random() * Math.floor(issues.length - 1))

let key = cmd.first ? 0 : Math.floor(Math.random() * Math.floor(output.length - 1))
// Call the log functionality, output the result to the console.
let output = await log(issues[key], projects[input].name)

// Log the issue!
console.log(output[key].toString())
console.log(output.toString())

if (cmd.open) {
opn(issues[key].url)
Expand Down
34 changes: 15 additions & 19 deletions lib/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,23 @@ var boxenOptions = {
borderColor: 'green',
borderStyle: 'round'
}
async function log (issues, project) {
var set = []
for (var issue in issues) {
var data = {
leftpad: ' ',
doublepad: ' ',
header: 'Good First Issue in ' + chalk.yellow(project) + ': ',
title: chalk.green(issues[issue].title),
issue: chalk.cyan('#' + issues[issue].pr),
state: chalk.green(issues[issue].state),
unassigned: chalk.green('unassigned!'), // All assigned issues are being filtered out at the search level, so all issues will always be unassigned
link: chalk.cyan(issues[issue].url),
repo: chalk.green(issues[issue].url.toString().slice(19, issues[issue].url.toString().indexOf('/issue'))),
labels: issues[issue].labels
}
async function log (issue, project) {
const data = {
leftpad: ' ',
doublepad: ' ',
header: 'Good First Issue in ' + chalk.yellow(project) + ': ',
title: chalk.green(issue.title),
issue: chalk.cyan('#' + issue.pr),
state: chalk.green(issue.state),
unassigned: chalk.green('unassigned!'), // All assigned issues are being filtered out at the search level, so all issues will always be unassigned
link: chalk.cyan(issue.url),
repo: chalk.green(issue.url.toString().slice(19, issue.url.toString().indexOf('/issue'))),
labels: issue.labels
}

var output = '\n' + boxen(data.header + '\n\n' + ' - Title: ' + data.title + '\n' + ' - Repository: ' + data.repo + '\n' + ' - Issue: ' + data.issue + '\n' + ' - Status: ' + data.state + '\n' + ' - Assigned to: ' + data.unassigned + '\n\n' + 'Start now: ' + data.link, boxenOptions) + '\n'
const output = '\n' + boxen(data.header + '\n\n' + ' - Title: ' + data.title + '\n' + ' - Repository: ' + data.repo + '\n' + ' - Issue: ' + data.issue + '\n' + ' - Status: ' + data.state + '\n' + ' - Assigned to: ' + data.unassigned + '\n\n' + 'Start now: ' + data.link, boxenOptions) + '\n'

set.push(output)
}
return set
return output
}

module.exports = log

0 comments on commit 739bbfd

Please sign in to comment.