Comparing version 1.0.4 to 1.0.5
14
cli.js
@@ -177,6 +177,10 @@ // Tools for writing command-line apps in Node. | ||
applyStyles: function(text, styles) { | ||
// apply one or more chalk styles to text string | ||
// apply one or more chalk styles or functions to text string | ||
if (!styles) return text; | ||
styles.forEach( function(style) { | ||
text = chalk[style]( text ); | ||
if (typeof style === 'function') { | ||
text = style( text ); | ||
} else { | ||
text = chalk[style]( text ); | ||
} | ||
} ); | ||
@@ -550,3 +554,3 @@ return text; | ||
end: function() { | ||
end: function(erase) { | ||
// end of progress session | ||
@@ -556,3 +560,5 @@ if (!cli.tty()) return; | ||
this.erase(); | ||
if (erase !== false) { | ||
this.erase(); | ||
} | ||
clearTimeout( this.timer ); | ||
@@ -559,0 +565,0 @@ this.running = false; |
{ | ||
"name": "pixl-cli", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Tools for building command-line apps for Node.js.", | ||
@@ -25,6 +25,6 @@ "author": "Joseph Huckaby <jhuckaby@gmail.com>", | ||
"dependencies": { | ||
"pixl-class": "*", | ||
"pixl-args": "*", | ||
"pixl-tools": "*", | ||
"chalk": "^1.1.1", | ||
"pixl-class": "^1.0.0", | ||
"pixl-args": "^1.0.0", | ||
"pixl-tools": "^1.0.0", | ||
"chalk": "^2.4.1", | ||
"string-width": "^1.0.1", | ||
@@ -31,0 +31,0 @@ "widest-line": "^1.0.0", |
@@ -235,3 +235,3 @@ # Overview | ||
| `width` | An optional fixed width. If specified and the string exceeds the width, it will be word-wrapped. | | ||
| `styles` | An array of [chalk](https://www.npmjs.com/package/chalk) styles to apply to the box border graphics, defaults to `["gray"]`. | | ||
| `styles` | An array of [chalk](https://www.npmjs.com/package/chalk) styles or functions to apply to the box border graphics, defaults to `["gray"]`. | | ||
| `hspace` | An optional number of spaces to insert on the left and right sides of the text (defaults to `1`). | | ||
@@ -249,3 +249,3 @@ | `vspace` | An optional number of vertical lines to insert above and below the text (defaults to `0`). | | ||
width: 40, | ||
styles: ["magenta"], | ||
styles: ["magenta", function( text ) { return text.toUpperCase() }], | ||
hspace: 2, | ||
@@ -367,5 +367,5 @@ vspace: 1, | ||
|---------------|-------------| | ||
| `headerStyles` | An array of [chalk](https://www.npmjs.com/package/chalk) styles to apply to the header cell text. | | ||
| `textStyles` | An array of [chalk](https://www.npmjs.com/package/chalk) styles to apply to the table cell text. | | ||
| `borderStyles` | An array of [chalk](https://www.npmjs.com/package/chalk) styles to apply to the border graphics. | | ||
| `headerStyles` | An array of [chalk](https://www.npmjs.com/package/chalk) styles or functions to apply to the header cell text. | | ||
| `textStyles` | An array of [chalk](https://www.npmjs.com/package/chalk) styles or functions to apply to the table cell text. | | ||
| `borderStyles` | An array of [chalk](https://www.npmjs.com/package/chalk) styles or functions to apply to the border graphics. | | ||
| `indent` | Number of characters to indent the table by (defaults to `0`). | | ||
@@ -379,3 +379,3 @@ | ||
headerStyles: ["bold", "yellow"], | ||
textStyles: ["cyan"], | ||
textStyles: ["cyan", function( text ) { return text.toUpperCase() }], | ||
borderStyles: ["gray"], | ||
@@ -387,3 +387,3 @@ indent: 0 | ||
Each of the three style keys should be set to an array of style names supported by the [chalk](https://www.npmjs.com/package/chalk) module. These are arrays because each component may contain multiple styles. For example, the `headerStyles` is rendered with both `yellow` and `bold` by default. | ||
Each of the three style keys should be set to an array of style names supported by the [chalk](https://www.npmjs.com/package/chalk) module or a custom function to support different text transformations. These are arrays because each component may contain multiple styles. For example, the `headerStyles` is rendered with both `yellow` and `bold` by default. | ||
@@ -491,3 +491,3 @@ Note that each text cell must only be one line (multi-line is not supported). | ||
The progress bar uses a set of color styles from the [chalk](https://www.npmjs.com/package/chalk) module for the spinner, braces, bar chunks, percentage display, remaining time, and your custom text (if applicable). To customize these, pass in a `styles` object with the following keys: | ||
The progress bar uses a set of color styles from the [chalk](https://www.npmjs.com/package/chalk) module or a custom function for the spinner, braces, bar chunks, percentage display, remaining time, and your custom text (if applicable). To customize these, pass in a `styles` object with the following keys: | ||
@@ -502,3 +502,3 @@ ```js | ||
remain: ['green'], | ||
text: [] | ||
text: [function( text ) { return text.toUpperCase() }] | ||
} | ||
@@ -508,3 +508,3 @@ }); | ||
Each key should be set to an array of styles supported by the [chalk](https://www.npmjs.com/package/chalk) module. These are arrays because each component may contain multiple styles. For example, by default the `spinner`, `bar` and `pct` are styled with both a color and `bold`. | ||
Each key should be set to an array of styles supported by the [chalk](https://www.npmjs.com/package/chalk) module or a function. These are arrays because each component may contain multiple styles. For example, by default the `spinner`, `bar` and `pct` are styled with both a color and `bold`. | ||
@@ -530,2 +530,7 @@ ### Automatic Width | ||
### Keep progress bar visible after it ends | ||
To keep the progress bar visible after it reaches 100%, just pass the value `false` to the | ||
`cli.progress.end()` function. This will prevent it from being erased from the screen. | ||
### Unicode or ASCII | ||
@@ -532,0 +537,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 3 instances in 1 package
46490
488
1
637
3
+ Addedansi-styles@3.2.1(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedsupports-color@5.5.0(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedchalk@1.1.3(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedsupports-color@2.0.0(transitive)
Updatedchalk@^2.4.1
Updatedpixl-args@^1.0.0
Updatedpixl-class@^1.0.0
Updatedpixl-tools@^1.0.0