Last active
March 26, 2017 03:09
-
-
Save lirantal/f3f805117e32e6f9a6f311f031d402b9 to your computer and use it in GitHub Desktop.
LicenseWatch-CLI With Blessed UI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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