Socket
Socket
Sign inDemoInstall

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.6.3 to 5.7.0

3

lib/prompt.js

@@ -18,2 +18,5 @@ 'use strict';

process.stdin.resume();
if (!process.stdin.isTTY) {
throw new Error(`need to prompt for ${options.name || options.prompt} but stdin is not a tty`);
}
process.stdin.setRawMode(true);

@@ -20,0 +23,0 @@ }

@@ -62,3 +62,48 @@ 'use strict';

/**
* styledNameValues logs an array of {name: '', values: ['']} objects in a consistent style
*
* @example
* styledNameValues([{name: "Collaborators", values: ["user1@example.com", "user2@example.com"]},
* {name: "Name", values: ["myapp"]}])
* Collaborators: user1@example.com
* user2@example.com
* Name: myapp
*
* @param {nameValues} nameValues
* @returns {null}
*/
function styledNameValues(nameValues) {
let keys = nameValues.map(function(nameValue) { return nameValue.name; });
let keyLengths = keys.map(function(name) { return name.toString().length; });
let maxKeyLength = Math.max.apply(Math, keyLengths) + 2;
function pp(obj) {
if (typeof obj === 'string' || typeof obj === 'number') {
return obj;
} else if (typeof obj === 'object') {
return Object.keys(obj).map(k => k + ': ' + cli.inspect(obj[k])).join(', ');
} else {
return cli.inspect(obj);
}
}
function logKeyValue(key, value) {
cli.log(`${key}:`+' '.repeat(maxKeyLength - key.length-1)+pp(value));
}
for (var nameValue of nameValues) {
let value = nameValue.values;
if (Array.isArray(value)) {
if (value.length > 0) {
logKeyValue(nameValue.name, value[0]);
for (var e of value.slice(1)) {
cli.log(" ".repeat(maxKeyLength) + pp(e));
}
}
} else if (value !== null && value !== undefined) {
logKeyValue(nameValue.name, value);
}
}
}
module.exports.styledHeader = styledHeader;
module.exports.styledObject = styledObject;
module.exports.styledNameValues = styledNameValues;

2

lib/table.js

@@ -13,3 +13,3 @@ 'use strict';

printRow: function(cells) {
this.printLine(cells.join(this.colSep));
this.printLine(cells.join(this.colSep).trimRight());
},

@@ -16,0 +16,0 @@ printHeader: function(cells) {

{
"name": "heroku-cli-util",
"version": "5.6.3",
"version": "5.7.0",
"description": "Set of helpful CLI utilities",

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

@@ -18,1 +18,15 @@ 'use strict';

});
describe('styledNameValues', function () {
it('prints out a styled set of name values', function () {
cli.styledHash([{name: 'Name', values: ["myapp"]}, {name: 'Collaborators', values: ["user1@example.com", "user2@example.com"]}]);
expect(cli.color.stripColor(cli.stdout)).to.contain('Collaborators: user1@example.com\n' +
' user2@example.com\n' +
'Name: myapp\n');
});
it('prints out a styled header', function () {
cli.styledHeader('MyApp');
expect(cli.color.stripColor(cli.stdout)).to.contain('=== MyApp\n');
});
});
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