Skip to content

Commit

Permalink
feat(pull-request): Replace cli-table with cli-table2 & Improve table…
Browse files Browse the repository at this point in the history
… formatting

node-gh#589
  • Loading branch information
hamxabaig committed Dec 29, 2018
1 parent 185c9f6 commit b26bae8
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 50 deletions.
13 changes: 8 additions & 5 deletions lib/cmds/pull-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
// -- Requires -------------------------------------------------------------------------------------

var async = require('async'),
Table = require('cli-table'),
wrap = require('word-wrap'),
Table = require('cli-table2'),
wrap = require('wordwrap'),
marked = require('marked'),
TerminalRenderer = require('marked-terminal'),
base = require('../base'),
Expand Down Expand Up @@ -485,20 +485,23 @@ PullRequest.prototype.printPullsInfoTable_ = function(pulls) {
}

function getPRBody(pull, length) {
var title = wrap(pull.title, { indent: '', width: length })
var title = wrap(length)(pull.title)
var body = ''

if (showDetails) {
marked.setOptions({
renderer: new TerminalRenderer(),
renderer: new TerminalRenderer({
width: length,
reflowText: true
}),
})
body += logger.colors.blue('Title:')
body += '\n\n'
body += title
body += '\n\n'
body += logger.colors.blue('Body:')
body += '\n\n'
body += marked(wrap(pull.body || 'N/A', { indent: '', width: length }))
body += marked(pull.body || 'N/A')
} else {
body += title
}
Expand Down
134 changes: 91 additions & 43 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"dependencies": {
"@babel/polyfill": "^7.2.5",
"async": "~1.5.0",
"cli-table": "^0.3.1",
"cli-table2": "^0.2.0",
"colors": "~1.1.2",
"github": "~0.2.4",
"handlebars": "~4.0.4",
Expand All @@ -104,7 +104,6 @@
"update-notifier": "~0.5.0",
"userhome": "~1.0.0",
"which": "~1.2.0",
"word-wrap": "^1.2.3",
"wordwrap": "~1.0.0"
},
"devDependencies": {
Expand Down

0 comments on commit b26bae8

Please sign in to comment.