Socket
Socket
Sign inDemoInstall

cli-width

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.1.0

LICENSE

8

index.js

@@ -17,2 +17,10 @@ 'use strict';

else {
if (process.env.CLI_WIDTH) {
var width = parseInt(process.env.CLI_WIDTH, 10);
if (!isNaN(width)) {
return width;
}
}
return exports.defaultWidth;

@@ -19,0 +27,0 @@ }

2

package.json
{
"name": "cli-width",
"version": "1.0.1",
"version": "1.1.0",
"description": "Get stdout window width, with two fallbacks, tty and then a default.",

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

cli-width
=========
Get stdout window width, with two fallbacks, `tty` and then a default.
Get stdout window width, with three fallbacks, `tty`, a custom environment variable and then a default.

@@ -20,2 +20,4 @@ ## Usage

You can also set the `CLI_WIDTH` environment variable.
If none of the methods are supported, the default is `0` and

@@ -22,0 +24,0 @@ can be changed via `cliWidth.defaultWidth = 200;`.

@@ -28,2 +28,21 @@ 'use strict';

test('uses custom env var', function (t) {
tty.getWindowSize = undefined;
process.env.CLI_WIDTH = 30;
t.equal(lib(), 30, 'equal to mocked, 30');
delete process.env.CLI_WIDTH;
t.end();
});
test('uses default if env var is not a number', function (t) {
process.env.CLI_WIDTH = 'foo';
t.equal(lib(), 0, 'default unset value, 0');
delete process.env.CLI_WIDTH;
t.end();
});
test('uses default', function (t) {

@@ -30,0 +49,0 @@ tty.getWindowSize = undefined;

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc