Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

heroku-cli-util

Package Overview
Dependencies
Maintainers
2
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

heroku-cli-util - npm Package Compare versions

Comparing version 5.4.5 to 5.4.6

3

index.js

@@ -26,3 +26,4 @@ 'use strict';

exports.styledHeader = styled.styledHeader;
exports.styledHash = styled.styledHash;
exports.styledObject = styled.styledObject;
exports.styledHash = styled.styledObject;
exports.rollbar = require('./lib/rollbar');

@@ -7,5 +7,10 @@ 'use strict';

function errtermwidth() {
if (!process.stderr.isTTY) return 80;
return process.stderr.getWindowSize()[0];
}
function wrap (msg) {
return linewrap(6,
process.stderr.getWindowSize()[0], {
errtermwidth(), {
skipScheme: 'ansi-color'

@@ -12,0 +17,0 @@ })(msg || '');

'use strict';
let cli = require('..');
let util = require('util');
let inflection = require('inflection');
function logKeyValue(key, value, maxKeyLength) {
cli.log(inflection.titleize(key)+':'+' '.repeat(maxKeyLength - key.length-1)+value);
}
/**

@@ -24,6 +21,6 @@ * styledHeader logs in a consistent header style

/**
* styledHash logs a hash in a consistent columnar style
* styledObject logs an object in a consistent columnar style
*
* @example
* styledHash({name: "myapp", collaborators: ["user1@example.com", "user2@example.com"]})
* styledObject({name: "myapp", collaborators: ["user1@example.com", "user2@example.com"]})
* Collaborators: user1@example.com

@@ -33,26 +30,30 @@ * user2@example.com

*
* @param {hash} hash of data to print
* @param {obj} object data to print
* @param {keys} optional array of keys to sort/filter output
* @returns {null}
*/
function styledHash(hash, keys) {
let keyLengths = Object.keys(hash).map(function(key) {
return key.toString().length;
});
function styledObject(obj, keys) {
let keyLengths = Object.keys(obj).map(function(key) { return key.toString().length; });
let maxKeyLength = Math.max.apply(Math, keyLengths) + 2;
keys = keys || Object.keys(hash).sort();
for (var key_index in keys) {
if (keys.hasOwnProperty(key_index)) {
let value = hash[keys[key_index]];
if(typeof value === 'object') {
if(value.length > 0) {
let elements = value.sort();
logKeyValue(keys[key_index], elements[0], maxKeyLength);
for (var i = 1; i < elements.length; i++) {
cli.log(" ".repeat(maxKeyLength) + elements[i]);
}
function pp(obj) {
if (typeof obj === 'string' || typeof obj === 'number') {
return obj;
} else {
return util.inspect(obj);
}
}
function logKeyValue(key, value) {
cli.log(inflection.titleize(key)+':'+' '.repeat(maxKeyLength - key.length-1)+pp(value));
}
for (var key of (keys || Object.keys(obj).sort())) {
let value = obj[key];
if (Array.isArray(value)) {
if (value.length > 0) {
logKeyValue(key, value[0]);
for (var e of value.slice(1)) {
cli.log(" ".repeat(maxKeyLength) + pp(e));
}
} else if (value !== null && value !== undefined) {
logKeyValue(keys[key_index], value, maxKeyLength);
}
} else if (value !== null && value !== undefined) {
logKeyValue(key, value);
}

@@ -63,2 +64,2 @@ }

module.exports.styledHeader = styledHeader;
module.exports.styledHash = styledHash;
module.exports.styledObject = styledObject;
{
"name": "heroku-cli-util",
"version": "5.4.5",
"version": "5.4.6",
"description": "Set of helpful CLI utilities",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc