npmlog
Advanced tools
Comparing version 4.1.2 to 5.0.0
160
log.js
@@ -16,7 +16,8 @@ 'use strict' | ||
stream = newStream | ||
if (this.gauge) this.gauge.setWriteTo(stream, stream) | ||
if (this.gauge) | ||
this.gauge.setWriteTo(stream, stream) | ||
}, | ||
get: function () { | ||
return stream | ||
} | ||
}, | ||
}) | ||
@@ -50,4 +51,4 @@ | ||
':', | ||
{type: 'logline', kerning: 1, default: ''} | ||
] | ||
{type: 'logline', kerning: 1, default: ''}, | ||
], | ||
}) | ||
@@ -82,6 +83,10 @@ | ||
log.enableProgress = function () { | ||
if (this.progressEnabled) return | ||
if (this.progressEnabled) | ||
return | ||
this.progressEnabled = true | ||
this.tracker.on('change', this.showProgress) | ||
if (this._pause) return | ||
if (this._paused) | ||
return | ||
this.gauge.enable() | ||
@@ -91,3 +96,4 @@ } | ||
log.disableProgress = function () { | ||
if (!this.progressEnabled) return | ||
if (!this.progressEnabled) | ||
return | ||
this.progressEnabled = false | ||
@@ -104,6 +110,16 @@ this.tracker.removeListener('change', this.showProgress) | ||
Object.keys(log).forEach(function (P) { | ||
if (P[0] === '_') return | ||
if (trackerConstructors.filter(function (C) { return C === P }).length) return | ||
if (tracker[P]) return | ||
if (typeof log[P] !== 'function') return | ||
if (P[0] === '_') | ||
return | ||
if (trackerConstructors.filter(function (C) { | ||
return C === P | ||
}).length) | ||
return | ||
if (tracker[P]) | ||
return | ||
if (typeof log[P] !== 'function') | ||
return | ||
var func = log[P] | ||
@@ -119,3 +135,5 @@ tracker[P] = function () { | ||
var func = tracker[C] | ||
tracker[C] = function () { return mixinLog(func.apply(tracker, arguments)) } | ||
tracker[C] = function () { | ||
return mixinLog(func.apply(tracker, arguments)) | ||
} | ||
}) | ||
@@ -128,7 +146,11 @@ } | ||
trackerConstructors.forEach(function (C) { | ||
log[C] = function () { return mixinLog(this.tracker[C].apply(this.tracker, arguments)) } | ||
log[C] = function () { | ||
return mixinLog(this.tracker[C].apply(this.tracker, arguments)) | ||
} | ||
}) | ||
log.clearProgress = function (cb) { | ||
if (!this.progressEnabled) return cb && process.nextTick(cb) | ||
if (!this.progressEnabled) | ||
return cb && process.nextTick(cb) | ||
this.gauge.hide(cb) | ||
@@ -138,5 +160,9 @@ } | ||
log.showProgress = function (name, completed) { | ||
if (!this.progressEnabled) return | ||
if (!this.progressEnabled) | ||
return | ||
var values = {} | ||
if (name) values.section = name | ||
if (name) | ||
values.section = name | ||
var last = log.record[log.record.length - 1] | ||
@@ -147,3 +173,5 @@ if (last) { | ||
var logline = this._format(disp, log.style[last.level]) | ||
if (last.prefix) logline += ' ' + this._format(last.prefix, this.prefixStyle) | ||
if (last.prefix) | ||
logline += ' ' + this._format(last.prefix, this.prefixStyle) | ||
logline += ' ' + last.message.split(/\r?\n/)[0] | ||
@@ -159,7 +187,10 @@ values.logline = logline | ||
this._paused = true | ||
if (this.progressEnabled) this.gauge.disable() | ||
if (this.progressEnabled) | ||
this.gauge.disable() | ||
} | ||
log.resume = function () { | ||
if (!this._paused) return | ||
if (!this._paused) | ||
return | ||
this._paused = false | ||
@@ -172,3 +203,4 @@ | ||
}, this) | ||
if (this.progressEnabled) this.gauge.enable() | ||
if (this.progressEnabled) | ||
this.gauge.enable() | ||
} | ||
@@ -194,24 +226,26 @@ | ||
// resolve stack traces to a plain string. | ||
if (typeof arg === 'object' && arg && | ||
(arg instanceof Error) && arg.stack) { | ||
if (typeof arg === 'object' && arg instanceof Error && arg.stack) { | ||
Object.defineProperty(arg, 'stack', { | ||
value: stack = arg.stack + '', | ||
enumerable: true, | ||
writable: true | ||
writable: true, | ||
}) | ||
} | ||
} | ||
if (stack) a.unshift(stack + '\n') | ||
if (stack) | ||
a.unshift(stack + '\n') | ||
message = util.format.apply(util, a) | ||
var m = { id: id++, | ||
level: lvl, | ||
prefix: String(prefix || ''), | ||
message: message, | ||
messageRaw: a } | ||
var m = { | ||
id: id++, | ||
level: lvl, | ||
prefix: String(prefix || ''), | ||
message: message, | ||
messageRaw: a, | ||
} | ||
this.emit('log', m) | ||
this.emit('log.' + lvl, m) | ||
if (m.prefix) this.emit(m.prefix, m) | ||
if (m.prefix) | ||
this.emit(m.prefix, m) | ||
@@ -234,8 +268,15 @@ this.record.push(m) | ||
} | ||
if (this.progressEnabled) this.gauge.pulse(m.prefix) | ||
if (this.progressEnabled) | ||
this.gauge.pulse(m.prefix) | ||
var l = this.levels[m.level] | ||
if (l === undefined) return | ||
if (l < this.levels[this.level]) return | ||
if (l > 0 && !isFinite(l)) return | ||
if (l === undefined) | ||
return | ||
if (l < this.levels[this.level]) | ||
return | ||
if (l > 0 && !isFinite(l)) | ||
return | ||
// If 'disp' is null or undefined, use the lvl as a default | ||
@@ -252,3 +293,5 @@ // Allows: '', 0 as valid disp | ||
var p = m.prefix || '' | ||
if (p) this.write(' ') | ||
if (p) | ||
this.write(' ') | ||
this.write(p, this.prefixStyle) | ||
@@ -261,3 +304,4 @@ this.write(' ' + line + '\n') | ||
log._format = function (msg, style) { | ||
if (!stream) return | ||
if (!stream) | ||
return | ||
@@ -268,14 +312,27 @@ var output = '' | ||
var settings = [] | ||
if (style.fg) settings.push(style.fg) | ||
if (style.bg) settings.push('bg' + style.bg[0].toUpperCase() + style.bg.slice(1)) | ||
if (style.bold) settings.push('bold') | ||
if (style.underline) settings.push('underline') | ||
if (style.inverse) settings.push('inverse') | ||
if (settings.length) output += consoleControl.color(settings) | ||
if (style.beep) output += consoleControl.beep() | ||
if (style.fg) | ||
settings.push(style.fg) | ||
if (style.bg) | ||
settings.push('bg' + style.bg[0].toUpperCase() + style.bg.slice(1)) | ||
if (style.bold) | ||
settings.push('bold') | ||
if (style.underline) | ||
settings.push('underline') | ||
if (style.inverse) | ||
settings.push('inverse') | ||
if (settings.length) | ||
output += consoleControl.color(settings) | ||
if (style.beep) | ||
output += consoleControl.beep() | ||
} | ||
output += msg | ||
if (this.useColor()) { | ||
if (this.useColor()) | ||
output += consoleControl.color('reset') | ||
} | ||
return output | ||
@@ -285,3 +342,4 @@ } | ||
log.write = function (msg, style) { | ||
if (!stream) return | ||
if (!stream) | ||
return | ||
@@ -293,3 +351,5 @@ stream.write(this._format(msg, style)) | ||
// If 'disp' is null or undefined, use the lvl as a default | ||
if (disp == null) disp = lvl | ||
if (disp == null) | ||
disp = lvl | ||
this.levels[lvl] = n | ||
@@ -301,5 +361,5 @@ this.style[lvl] = style | ||
a[0] = lvl | ||
for (var i = 0; i < arguments.length; i++) { | ||
for (var i = 0; i < arguments.length; i++) | ||
a[i + 1] = arguments[i] | ||
} | ||
return this.log.apply(this, a) | ||
@@ -306,0 +366,0 @@ }.bind(this) |
@@ -5,3 +5,3 @@ { | ||
"description": "logger for npm", | ||
"version": "4.1.2", | ||
"version": "5.0.0", | ||
"repository": { | ||
@@ -16,15 +16,20 @@ "type": "git", | ||
"scripts": { | ||
"test": "standard && tap test/*.js" | ||
"test": "tap test/*.js --branches=95", | ||
"npmclilint": "npmcli-lint", | ||
"lint": "npm run npmclilint -- \"*.*js\" \"test/**/*.*js\"", | ||
"lintfix": "npm run lint -- --fix", | ||
"posttest": "npm run lint --", | ||
"postsnap": "npm run lintfix --" | ||
}, | ||
"dependencies": { | ||
"are-we-there-yet": "~1.1.2", | ||
"console-control-strings": "~1.1.0", | ||
"gauge": "~2.7.3", | ||
"set-blocking": "~2.0.0" | ||
"are-we-there-yet": "^1.1.5", | ||
"console-control-strings": "^1.1.0", | ||
"gauge": "^3.0.0", | ||
"set-blocking": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"standard": "~7.1.2", | ||
"tap": "~5.7.3" | ||
"@npmcli/lint": "^1.0.1", | ||
"tap": "^15.0.9" | ||
}, | ||
"license": "ISC" | ||
} |
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
304
16330
4
1
+ Addedansi-regex@5.0.1(transitive)
+ Addedaproba@2.0.0(transitive)
+ Addedcolor-support@1.1.3(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedgauge@3.0.2(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedaproba@1.2.0(transitive)
- Removedcode-point-at@1.1.0(transitive)
- Removedgauge@2.7.4(transitive)
- Removedis-fullwidth-code-point@1.0.0(transitive)
- Removednumber-is-nan@1.0.1(transitive)
- Removedstring-width@1.0.2(transitive)
- Removedstrip-ansi@3.0.1(transitive)
Updatedare-we-there-yet@^1.1.5
Updatedgauge@^3.0.0
Updatedset-blocking@^2.0.0