Comparing version
36
log.js
@@ -9,2 +9,5 @@ 'use strict' | ||
var ansi = require('ansi') | ||
var setBlocking = require('set-blocking') | ||
setBlocking(true) | ||
log.cursor = ansi(process.stderr) | ||
@@ -18,2 +21,3 @@ log.stream = process.stderr | ||
this.cursor.enabled = true | ||
this.gauge.setTheme({hasColor: colorEnabled, hasUnicode: unicodeEnabled}) | ||
} | ||
@@ -23,2 +27,3 @@ log.disableColor = function () { | ||
this.cursor.enabled = false | ||
this.gauge.setTheme({hasColor: colorEnabled, hasUnicode: unicodeEnabled}) | ||
} | ||
@@ -29,3 +34,3 @@ | ||
log.gauge = new Gauge(log.cursor) | ||
log.gauge = new Gauge(log.cursor, {tty: log.stream}) | ||
log.tracker = new Progress.TrackerGroup() | ||
@@ -36,18 +41,20 @@ | ||
var gaugeTheme = undefined | ||
var unicodeEnabled = undefined | ||
log.enableUnicode = function () { | ||
gaugeTheme = Gauge.unicode | ||
log.gauge.setTheme(gaugeTheme) | ||
unicodeEnabled = true | ||
this.gauge.setTheme({hasColor: colorEnabled, hasUnicode: unicodeEnabled}) | ||
} | ||
log.disableUnicode = function () { | ||
gaugeTheme = Gauge.ascii | ||
log.gauge.setTheme(gaugeTheme) | ||
unicodeEnabled = false | ||
this.gauge.setTheme({hasColor: colorEnabled, hasUnicode: unicodeEnabled}) | ||
} | ||
var gaugeTemplate = undefined | ||
log.setGaugeThemeset = function (themes) { | ||
this.gauge.setThemeset(themes) | ||
} | ||
log.setGaugeTemplate = function (template) { | ||
gaugeTemplate = template | ||
log.gauge.setTemplate(gaugeTemplate) | ||
this.gauge.setTemplate(template) | ||
} | ||
@@ -103,5 +110,5 @@ | ||
log.clearProgress = function () { | ||
if (!this.progressEnabled) return | ||
this.gauge.hide() | ||
log.clearProgress = function (cb) { | ||
if (!this.progressEnabled) return cb && process.nextTick(cb) | ||
this.gauge.hide(cb) | ||
} | ||
@@ -211,6 +218,3 @@ | ||
this.cursor = ansi(this.stream, { enabled: colorEnabled }) | ||
var options = {} | ||
if (gaugeTheme != null) options.theme = gaugeTheme | ||
if (gaugeTemplate != null) options.template = gaugeTemplate | ||
this.gauge = new Gauge(options, this.cursor) | ||
this.gauge.setWriteTo(this.cursor, this.stream) | ||
} | ||
@@ -217,0 +221,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"description": "logger for npm", | ||
"version": "2.0.4", | ||
"version": "3.0.0", | ||
"repository": { | ||
@@ -21,3 +21,4 @@ "type": "git", | ||
"are-we-there-yet": "~1.1.2", | ||
"gauge": "~1.2.5" | ||
"gauge": "~2.5.0", | ||
"set-blocking": "~2.0.0" | ||
}, | ||
@@ -24,0 +25,0 @@ "devDependencies": { |
@@ -101,4 +101,10 @@ # npmlog | ||
Overrides the default gauge template. | ||
Set a template for outputting the progress bar. See the [gauge documentation] for details. | ||
[gauge documentation]: https://npmjs.com/package/gauge | ||
## log.setGaugeThemeset(themes) | ||
Select a themeset to pick themes from for the progress bar. See the [gauge documentation] for details. | ||
## log.pause() | ||
@@ -197,1 +203,10 @@ | ||
* `messageRaw` {Array} Arguments to `util.format()` | ||
# Blocking TTYs | ||
We use [`set-blocking`](https://npmjs.com/package/set-blocking) to set | ||
stderr and stdout blocking if they are tty's and have the setBlocking call. | ||
This is a work around for an issue in early versions of Node.js 6.x, which | ||
made stderr and stdout non-blocking on OSX. (They are always blocking | ||
Windows and were never blocking on Linux.) `npmlog` needs them to be blocking | ||
so that it can allow output to stdout and stderr to be interlaced. |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
14205
7.23%218
0.93%211
7.65%0
-100%4
33.33%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
Updated