multi-progress-bars
Advanced tools
Comparing version 2.0.3 to 2.0.5
@@ -5,2 +5,16 @@ # Changelog | ||
### [2.0.5](https://github.com/kamiyo/multi-progress-bars/compare/v2.0.4...v2.0.5) (2020-11-05) | ||
### Bug Fixes | ||
* **dep:** Updated dependencies ([3cdd05f](https://github.com/kamiyo/multi-progress-bars/commit/3cdd05f382ff3e7fd316558b17ba13fbca2f46c6)) | ||
### [2.0.4](https://github.com/kamiyo/multi-progress-bars/compare/v2.0.3...v2.0.4) (2020-11-05) | ||
### Bug Fixes | ||
* **bug:** in some cases, after SIGINT, this.stream becomes undefined, so use null-chaining for stream writes. ([4035f52](https://github.com/kamiyo/multi-progress-bars/commit/4035f52bed9282450ee680d344e3bcbf51d377b9)) | ||
### [2.0.3](https://github.com/kamiyo/multi-progress-bars/compare/v2.0.2...v2.0.3) (2020-09-25) | ||
@@ -7,0 +21,0 @@ |
@@ -5,9 +5,11 @@ 'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var chalk = require('chalk'); | ||
var path = require('path'); | ||
var stringWidth = _interopDefault(require('string-width')); | ||
var stringWidth = require('string-width'); | ||
var util = require('util'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var stringWidth__default = /*#__PURE__*/_interopDefaultLegacy(stringWidth); | ||
/*! ***************************************************************************** | ||
@@ -76,3 +78,3 @@ Copyright (c) Microsoft Corporation. | ||
const clampString = (message, width) => { | ||
while (stringWidth(message) > width) { | ||
while (stringWidth__default['default'](message) > width) { | ||
// Can't be sure we are slicing off a character vs a control sequence or colors | ||
@@ -101,8 +103,10 @@ // so do it this way, checking each time. | ||
cleanup() { | ||
this.stream.write('\x1b[0m'); | ||
var _a; | ||
(_a = this.stream) === null || _a === void 0 ? void 0 : _a.write('\x1b[0m'); | ||
} | ||
init() { | ||
var _a; | ||
process.on('SIGINT', this.cleanup); | ||
const blank = '\n'.repeat(this.stream.rows) + CUP(0) + ED(ED_MODE.TO_END); | ||
this.stream.write(blank); | ||
(_a = this.stream) === null || _a === void 0 ? void 0 : _a.write(blank); | ||
} | ||
@@ -147,8 +151,10 @@ /** Add or Update Progress Entry | ||
writeLines(...indexes) { | ||
var _a; | ||
let writeString = indexes.reduce((prev, index) => { | ||
return prev += CUP(index) + this.progressBuffer[index]; | ||
}, ''); | ||
this.stream.write(writeString); | ||
(_a = this.stream) === null || _a === void 0 ? void 0 : _a.write(writeString); | ||
} | ||
refresh() { | ||
var _a; | ||
const outString = CUP(0) | ||
@@ -159,5 +165,6 @@ + this.progressBuffer.map((val) => val + EL(EL_MODE.TO_END)).join('\n') | ||
+ '\n'; | ||
this.stream.write(outString); | ||
(_a = this.stream) === null || _a === void 0 ? void 0 : _a.write(outString); | ||
} | ||
log(...data) { | ||
var _a; | ||
const writeString = util.format.apply(null, data); | ||
@@ -183,3 +190,3 @@ const clampedLines = writeString.split('\n').reduce((prev, curr) => { | ||
+ '\n'; | ||
this.stream.write(outString); | ||
(_a = this.stream) === null || _a === void 0 ? void 0 : _a.write(outString); | ||
} | ||
@@ -295,3 +302,3 @@ } | ||
// Calculated longest name to pad other names to. | ||
this.longestNameLength = Math.max(this.longestNameLength, stringWidth(name)); | ||
this.longestNameLength = Math.max(this.longestNameLength, stringWidth__default['default'](name)); | ||
// Reset promise for end hook | ||
@@ -298,0 +305,0 @@ this.promise = new Promise((res, _) => this.resolve = res); |
@@ -93,8 +93,10 @@ import { green } from 'chalk'; | ||
cleanup() { | ||
this.stream.write('\x1b[0m'); | ||
var _a; | ||
(_a = this.stream) === null || _a === void 0 ? void 0 : _a.write('\x1b[0m'); | ||
} | ||
init() { | ||
var _a; | ||
process.on('SIGINT', this.cleanup); | ||
const blank = '\n'.repeat(this.stream.rows) + CUP(0) + ED(ED_MODE.TO_END); | ||
this.stream.write(blank); | ||
(_a = this.stream) === null || _a === void 0 ? void 0 : _a.write(blank); | ||
} | ||
@@ -139,8 +141,10 @@ /** Add or Update Progress Entry | ||
writeLines(...indexes) { | ||
var _a; | ||
let writeString = indexes.reduce((prev, index) => { | ||
return prev += CUP(index) + this.progressBuffer[index]; | ||
}, ''); | ||
this.stream.write(writeString); | ||
(_a = this.stream) === null || _a === void 0 ? void 0 : _a.write(writeString); | ||
} | ||
refresh() { | ||
var _a; | ||
const outString = CUP(0) | ||
@@ -151,5 +155,6 @@ + this.progressBuffer.map((val) => val + EL(EL_MODE.TO_END)).join('\n') | ||
+ '\n'; | ||
this.stream.write(outString); | ||
(_a = this.stream) === null || _a === void 0 ? void 0 : _a.write(outString); | ||
} | ||
log(...data) { | ||
var _a; | ||
const writeString = format.apply(null, data); | ||
@@ -175,3 +180,3 @@ const clampedLines = writeString.split('\n').reduce((prev, curr) => { | ||
+ '\n'; | ||
this.stream.write(outString); | ||
(_a = this.stream) === null || _a === void 0 ? void 0 : _a.write(outString); | ||
} | ||
@@ -178,0 +183,0 @@ } |
{ | ||
"name": "multi-progress-bars", | ||
"version": "2.0.3", | ||
"version": "2.0.5", | ||
"description": "Multiple progress bars with option for indefinite spinners", | ||
@@ -37,9 +37,9 @@ "main": "dist/multi-progress-bars.cjs.js", | ||
"@types/node": "12", | ||
"@wessberg/rollup-plugin-ts": "^1.2.28", | ||
"rollup": "^2.22.1", | ||
"rollup-plugin-typescript2": "^0.27.1", | ||
"standard-version": "^8.0.2", | ||
"trash-cli": "^3.0.0", | ||
"tslib": "^2.0.0", | ||
"typescript": "^3.9.7" | ||
"@wessberg/rollup-plugin-ts": "^1.3.7", | ||
"rollup": "^2.33.1", | ||
"rollup-plugin-typescript2": "^0.29.0", | ||
"standard-version": "^9.0.0", | ||
"trash-cli": "^3.1.0", | ||
"tslib": "^2.0.3", | ||
"typescript": "^4.0.5" | ||
}, | ||
@@ -46,0 +46,0 @@ "dependencies": { |
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
58594
1075