cli-width
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -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 @@ } |
{ | ||
"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; |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
3579
6
66
31
6