Skip to content

Instantly share code, notes, and snippets.

@lirantal
Last active March 26, 2017 03:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lirantal/f3f805117e32e6f9a6f311f031d402b9 to your computer and use it in GitHub Desktop.
Save lirantal/f3f805117e32e6f9a6f311f031d402b9 to your computer and use it in GitHub Desktop.
LicenseWatch-CLI With Blessed UI
'use strict'
const LicenseWatch = require('licensewatch')
const blessed = require('blessed')
const blessedContrib = require('blessed-contrib')
const fs = require('fs')
const screen = blessed.screen()
var bar = blessedContrib.bar({
// set widget label
label: 'Licenses in Dependencies',
// center the widget on the screen
top: 'center',
left: 0,
// define vertical bar's layout
barWidth: 4,
barSpacing: 15,
// sets maximum value for bar height otherwise
// it defaults to 1
maxHeight: 100
})
screen.render()
const licenses = new LicenseWatch(getModulesDirectory())
licenses.fetch()
licenses.on('licensesSummary', (licenses) => {
const titles = Object.keys(licenses)
const values = Object.values(licenses)
screen.append(bar)
bar.setData({
titles: titles,
data: values
})
screen.render()
})
function getModulesDirectory() {
return process.cwd() + '/node_modules/**/package.json'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment